When you think about translating your content, you may think about the page “title” and “body”. However, fully translated content requires more attention. In this document, we explain what you need to know to starting translate your content in your sites.
Files Structure
setup files to translation
the language directory in (./local/languages/)
.
in this directory you must create one directory each language in your website.
you can change language directory from configuration.
Beginning Translate
in my case i want to create website with 2 languages (English, Arabic).
get correct translation as selected language
last thing we need to get translation as language visitor selected.
you have 3 ways to get translation.
echo logaty()->_x('translation-file.translation-key')
logaty()->__('translation-file.translation-key')
to return to our example
<?php
// as selected language
/* 1 */ echo logaty()->_x('home.welcome');
/* 2 echo directly */ logaty()->__('home.welcome');
// as given language parameter
/* 1 */ echo logaty()->_x('home.welcome', 'ar');
/* 2 echo directly */ logaty()->__('home.welcome', 'en');
output well be as selected language if second parameter not set.
<?php
echo logaty()->_x('home.welcome');
/** Output :
* if selected language is (arabic) : مرحبا بك في الصفحة الرئيسية للغاتي.
* if selected language is English : Welcome to Logaty Home Page.
*/
/** --------------- Force Translation Language ---------------- */
echo logaty()->x('home.welcome', 'en');
/** Output :
* if selected language is (arabic) : Welcome to Logaty Home Page.
* if selected language is English : Welcome to Logaty Home Page.
*/