Search the Community
Showing results for tags 'language translation'.
-
Hi Our simple code: <?php echo __("Welcome to our website"); ?> I have installed the following core modules: Language Support Language Support - Fields Language Support - Page Names Language Support - Tabs Translation export/import I added the translation text for both the default and Tamil languages for the sentence "Welcome to our website" in the admin interface. Please find the screenshots PW-dash1.png and PW-dash2.png However, we are facing an error when call this sentence in the following template file site/templates/test-lang.php. Error: Fatal error: Uncaught Error: Call to undefined function __() in E:\wamp\www\processwire-dev\site\templates\test-lang.php on line 3 ( ! ) Error: Call to undefined function __() in E:\wamp\www\processwire-dev\site\templates\test-lang.php on line 3 Please find the screenshot of PW-error.png Please suggest how to resolve this.
- 14 replies
-
- language
- languagesupport
-
(and 1 more)
Tagged with:
-
Hello for all. Maybe it's only me, but when I build some website in my native language (one language non-english website) I do not use/install "Language support" modules - do you do the same or it's only my wrong practice? In that case, all my development is "fixed" (eg. can't share some scripts/code with the community, or some custom module etc.), or if I install some "frontend" module from PW repository than, also, have to install and "Language support" modules, or do ugly job (rewrite module static phrases). Right now I found some solution (write it here) but in that case "Language Support" module installed (2 more database table, 1 template, 1 page, indexing, checking, processing etc...), but with hook addition inside "wire/core/LanguageFunctions.php" all that can be avoid. Also in that case all PW standard translation procedures stay the same, but also we get new custom translation options (like in one-language non-english websites I will use that principle, but in multilanguage will use native and fast PW principle). Thanks and regards for all. p.s. if this is a "spam" question (because write almost the same things here) then please administration to delete one of these two topics.
- 1 reply
-
- language translation
- custom translation
-
(and 1 more)
Tagged with:
-
Hello for all. This is not a topic about multilanguage websites, but mostly about one-language web sites and translation methods. In one-language none-english projects I don't install "Language Support" modules, but still use static English phrases in files ("Read more"...), and later translate that phrases using some of many options (eg. method + arrays). To simplifie this topic: if you build website in one none-english language (eg. Germany, Russian etc.) and, as example, want to use wonderfull "Pollino" Soma module, than you have to install "Language Support" module, or you will have "Vote" button at the form. And that's ok. But how to translate that module phrases without using "Language Support" modules? <- was my first idea. Also, all this is in connection with my custom development where I want to standardise some things, like translation of static phrases. Target: Leave, and respect native PW call for all phrases in English (__("Some text")) and use that standard principle in all projects (one language, or multilanguage). Idea: use hooks inside __() call and at the beginning, stop all next calls and procedures, and do some compare and replace job Problem: there is no hookable method for that job ("wire/core/LanguageFunctions.php") Currently working solution (example): // _func.php // prepend // Call Language Support module // You can comment next line if you have installed module // , or this will do the same job $module = wire('modules')->get('LanguageSupport'); // Here we rewrite response from module function translation( HookEvent $event ){ $event->return = translate( $event->arguments(1) ); } // These is the example where we do "find and replace" job // You can use different variant, like include dict. file function translate( $phrase ){ $dictionary = array( 'Read more' => 'Opširnije', 'Total votings:' => 'Ukupno glasova: ', 'Vote' => 'Glasaj', 'Name' => 'Ime i prezime', 'Message'=> 'Poruka', 'Subscribe' => 'Pošalji', 'Missing required value' => 'Ovo polje je obavezno', 'Next' => '>>', 'Prev' => '<<' ); return isset($dictionary[$phrase]) ? $dictionary[$phrase] : $phrase; } // This is the main part where we hook wire()->addHookAfter('LanguageTranslator::getTranslation', null, 'translation'); I didn't avoid "Language Support" installation, but with this I can translate all website phrases in one place (good if you need to translate 20 - 30 views with repeatable phrases, eg. "Read more"). Also with this no need to use custom translation methods (use default PW call (__("Some text")). p.s. also there is idea to hook append same 'textdomain' for all files/views Regards, Sasa