Jump to content

How could I remove translation strings from template files?


Recommended Posts

Currently, I have translation strings across different template files.

I experienced that, it is not convenience for text translation, as it required user to log-in at the pw's admin back-end.

And any one of the default language text changed, you have to re-translated on the other languages.

Therefore, I'm going to change this translation method.

I will put all translation strings on a single file, the structure will look like and may include in _init.php

$transationArray = array();

$transationArray['default']['text_message_1'] = "FEFDDFG@#@";
$transationArray['default']['text_message_2'] = "565@@DFSS";
$transationArray['default']['text_message_3'] = "ZXCDF@#$$##";

$transationArray['jpn']['text_message_1'] = "$%$%$@#$#";
$transationArray['jpn']['text_message_2'] = "HGH$%$%$";
$transationArray['jpn']['text_message_3'] = "%$%$%$%$";

Then in any of template file,

$stringTranslated = $translationArray[$user->language->name];

The rest of the code

I just use following to display the multi-language text string

$content .= $stringTranslated['text_message'];

My question is, for the original translation string in the template files,

Besides removing all the translation string variables, how could I remove from dataabse ? Are the translated strings stored in database ?

Link to comment
Share on other sites

You don't have to add strings exactly as the default language but keys too, eg. you can use __('text_message_1'). So you can add translation also for the default language in the admin.

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

No. You set translations in the admin, the translation file (aka textdomain) only marks strings to be translated. So if you add "__('key1');" to the translations.php, then you'll have to go to Languages in the admin, and select this file to translate. You'll see "key1" and you'll need to enter the translated string, eg. "Hola" for Spanish.

If you had 12 languages you would need only one key even then. You would need to add the same translation file to each language in the admin.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...