From 071ed8a316170392d6c7838b56fb628f02e1cf95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Rosa?= Date: Fri, 13 Oct 2023 15:04:39 +0100 Subject: [PATCH] Add Quick Start Guide to README --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/README.md b/README.md index 5c3e70f..8d34aa1 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,62 @@ composer require crosa7/leaf-omniglot [//]: # (```) +## Quick Start Guide + +### Create translation folder and files + +```php +// Create a folder named "locales" in your project root +// (you can also create in another place that makes more sense, just be aware to configure the path accordingly) + +// Create the following file inside the "locales" folder +en_US.locale.json + +// With the following content +{ + "welcome.title": "Hello World" +} +``` + +### Initialize Omniglot + +In your index.php file (if using MVC: public/index.php). Add these lines: + +```php +omniglot()->init( + [ + 'TRANSLATION_FILES_LOCATION' => './locales', + ] +); +``` + +### Add Language Switch Route + +In your routes file ("_app.php" for MVC and "index.php" for base Leaf) add this line: + +```php +omniglot()->addLanguageSwitchRoute(); +``` + +### Start Translating + +Now in your template file you can add the following: + +(this example is using blade as template engine but you can adjust according to your template engine) +```php +
+ +
+ +

{{ tl('welcome.title') }}

+``` + +You should then see inside the "h1" tag in your browser the text: Hello World + ## Basic Usage After installing omniglot, you need to create a folder where your translation files will live.