How to translate Ossn

I. CREATE YOUR OWN LANGUAGE FILE

  1. Download the latest Ossn archive from https://www.opensource-socialnetwork.org/download
  2. Unzip the archive on your local PC
  3. From inside the unpacked archive enter the folder locale

Currently, Ossn comes with 5 translations each represented by a file like ossn.xx.php.
xx is the identifier for the language used inside: de = German, en = English, fr = French, pt = Portuguese and ro = Romanian.

  1. Start a simple ASCII file editor capable of handling UTF-8 encoding (e.g. Notepad or Notepad++)
  2. Open the file of that language you feel most comfortable with. (Throughout this how-to we will use the English language file ossn.en.php as a reference)
  3. Scroll down to line 300 and study the list of available 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!

  1. Decide which identifier to use, select and copy it to your input buffer
  2. Scroll down to the end of the file and replace the identifier between the single quotation marks with the one you just copied.

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.

  1. From your editor's file menu, choose "Save AS" ossn.af.php
  2. Close your editor and back in the locale folder, verify that a 6th file named 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 beresulting 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

  1. Login to your Ossn adminstrator panel
  2. Disable cache
  3. Enable error reporting
  4. Start a file transfer utility of your choice (FTP tool or provider's Filemanager)
  5. Copy the file ossn.af.php you created in section I. to the locale folder of your website
  6. Refresh your Ossn adminstrator panel, under Site Settings -> Default Language "Afrikaans" should be available now
  7. Choose "Afrikaans", save this setting and log off
  8. Make your browser point to the startpage of your Website
  9. Everything should look ok so far, still untranslated of course :)

It'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!