Jump to content

Translate string __(' ') on _main.php


Cesco
 Share

Recommended Posts

Just now, Cesco said:

Thanks @bernhard you save my time ;)  ... i feel so stupid :)

glad it helped. actually i think that the usability of this site/module could be improved. it was also not self-explaining for me when i did my first steps with multilanguage setups... ;)

  • Like 1
Link to comment
Share on other sites

2 minutes ago, bernhard said:

glad it helped. actually i think that the usability of this site/module could be improved. it was also not self-explaining for me when i did my first steps with multilanguage setups... ;)

It comforts me :P

Thanks

Link to comment
Share on other sites

  • 1 month later...

you can put a function somewhere in your code (eg _functions.php):

function translate($string) {
  if($config->lang == 'en') {
    $translations = [
      'hallo welt' => 'hello world',
      ...
    ];
    return $translations[$string];
  }
  return $string;
}

echo translate('hallo welt'); // hallo welt

$config->lang = 'en';
echo translate('hallo welt'); // hello world

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thanks @bernhard !

In my particular case, I have a few ocurences of __('en_string') which I would like to apper as translated 'de_string' in the output.

I could modify the source(s) replacing strings statically, but that would be rather "quick and dirty".

Hm, maybe I could substitute the __() function with my own version...

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...