I. CREATE YOUR OWN LANGUAGE FILE
if you are using openteknik paid version downlead paid version from there first
)locale
OSSN uses 2 digit ISO 639-1 language codes http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
Currently, Ossn comes with 18 translations each represented by a file like ossn.xx
.php.
xx
is the identifier for the language used inside:
de
= Germanel
= Greeken
= Englisheo
= Esperantoes
= Spanishfr
= Frenchhe
= Hebrewhu
= Hungarianid
= Indonesianit
= Italianja
= Japaneseko
= Koreannl
= Dutchpt
= Portuguesero
= Romanianru
= Russiantr
= Turkishzh
= Chinese
Start a simple ASCII file editor (e.g. Notepad or Notepad++) and select UTF-8 encoding without BOM
ossn.en.php
as a reference)language identifiers
.Thus, if your native language is Afrikaans
for example, the identifier you have to use is af
. In case your language or exact dialect is not listed, choose an identifier which comes most close to one of the available languages. Don't 'invent' your own identifier - it wouldn't work!
If you did everything correctly, and assuming you want to continue with "Afrikaans" in our example, the old line
ossn_register_languages('en', $en);
must look like
ossn_register_languages('af', $en);
now. The next step is to create a new Afrikaans language file with the change you just made included.
ossn.af.php
. Again: Make sure, your file has been saved as UTF-8
- WITHOUT BOM
ossn.af.php
has in fact been created.II. WHAT YOU SHOULD KNOW IN ADVANCE
a) Keep the syntax
Basically each Ossn language file comes with a so-called assoziative Array, including a search key on the left and the corresponding translation on the right side:
$en = array(
'key:one' => 'Translation One
',
'key:two' => 'Translation Two
',
);
and the last line (you already know) which is adding this array to Ossn.
It is absolutely important to have in mind that a language file is in fact PHP code getting executed. And because of that you MUST leave the basic structure and syntax intact, otherwise the PHP interpreter will fail - leaving you with a blank white page. So be careful and only change what's marked RED in the listing above.
Even then, and since nobody's perfect, mistakes may happen. And before running into a situation like that you better make yourself comfortable with error logging and read: https://www.opensource-socialnetwork.org/wiki/view/1954/how-to-enable-ossn-error-reporting. This way the problem line will be listed in the file named error_log
for your convenience hence making it much easier to find and correct your mistake.
b) Placeholders
On translating you'll come across several lines including one or more %s
like
'%s has sent you a friend request'
At runtime the %s
is replaced by Ossn with a variable, in this case the member's fullname. Make sure to keep the exact number of placeholders with your translation, the position within your string may be varied, though. Thus, if it's more elegant with your language to put it like
'a friend request has been sent to you by %s'
feel free to do it that way.
c) 'Single' quotes and "double" quotes
You'll notice that the majority of strings are enclosed in single quotes.
These 'ticks' are a must-have for PHP to evaluate where a string starts and where it ends. And they are working perfectly as long as the string itself doesn't include any more single quotes.
That said, a string like
'It's free and always will be'
will be interpreted as string It
and a PHP confusing code skeleton of s free and always will be
resulting in a syntax error and a white page.
In cases like that the translation's start and end must be marked with double quotes like
"It's free and always will be"
d) Don't translate the line
'powered' => 'Powered by the Open Source Social Network.',
Doing so will make your site unaccessable!
III. START TRANSLATING
ossn.af.php
you created in section I. to the locale
folder of your websiteIt's up to you which way you proceed from here. You may either open your ossn.af.php
locally, translate some lines and copy the changed file onto your server again and again, or open ossn.af.php
on the website directly and make your changes there.
In both cases we highly recommend to make a backup of your last working version and not to translate too many lines at once. Just do it step by step and verify your translating results by refreshing your browser.
IV. Finalizing ...
When your done with translating Ossn's main language file, visit the Ossn subdirectory named components
. Each component comes with its own locale
directory and its own set of translation files. Again, pick the one you feel most comfortable with and repeat the steps you've learned.
At this stage it makes sense to install the Translation Check component (https://www.opensource-socialnetwork.org/component/view/1982/translation-check) which will help you keeping your translations up-to-date and complete.
Finally, there's one last location that you may want to translate in order to make a complete language file archive available to the Ossn community: It's located under installation/locales
.
Good luck!