Search the Community
Showing results for tags 'internationalization'.
-
Hey community, first of all: I love this CMS! But unfortunately my Code Internationalization (i18n) doesn´t work within included php files: I´m using the module Pro Fields Page Table, the regular Languages Support Module and no template caching. The website has 2 Languages (DE as default, EN as second language) Problem: Using <?php echo(__('Test')); ?> within /site/templates/home.php works without any problems and gets translated correctly However using <?php echo($this->_('Headline'));?> within /site/templates/components/component.php does not work. Note: using <?php echo(__('Headline'));?> in .../component.php throws an error and therefore cannot be used. Example: /site/templates/ce-includer.php (Template with the dynamic text-field 'filepath'): include('components/'.$page->filepath); this correclty includes the file "/site/templates/components/home-content.php" Code in home-content.php: <h1><?php echo($this->_('Headline'));?></h1> Output for both pages (DE and EN version - the string was translated to "Headline DE" in german and "Headline EN" in english): <h1>Headline</h1> Does anyone know how to use Code Internationalization in such a szenario? All the best and keep up the great work! Daniel
-
https://processwire.com/api/multi-language-support/code-i18n/ In the documentation about Code Internationalization the following is mentioned: Translatable strings In order to make a string translatable in your template or module code, you just have to wrap the original string in a $this->_() or __() function call: $out = $this->_("Live long and prosper"); // syntax within a class $out = __("Live long and prosper!"); // syntax outside of a class Inside my methods the first example of syntax in a class seems to work fine. Somehow the following code seems to throw a 500 Internal Server Error which states: Parse Error: syntax error, unexpected '$this' (T_VARIABLE) Example: class SomeModuleName extends WireData implements Module, ConfigurableModule { /** * Returns gender type * * @static * @return string */ private static $gender = array( 1 => $this->_("Male"), 2 => $this->_("Female"), ); } I can image since the module is not initialized or constructed yet that $this is not available at that spot. Any tips on how to be able to make those values multilanguage?
- 8 replies
-
- internationalization
- multi
-
(and 2 more)
Tagged with: