vxda Posted February 13, 2014 Share Posted February 13, 2014 Hi guys, is there a way to translate hardcoded html text for example: <div class="tabs"> <a href="#">Tab name in some language</a> <a href="#">Tab name in some language2</a> <a href="#">Tab name in some language3</a> </div> i know that we can do something like <?php if ($lang == 'en') { echo "<a href="#">Tab name in English languge</a>" } if ($lang == "other ") { echo "<a href="#">Tab name in other languge</a>" } I was thinking about module of some kind working like "Process Language Translator" or in code u use variable tags like : {lang-TabNameInSomeLanguage} <div class="tabs"> <a href="#">{lang-TabNameOne}</a> <a href="#">{lang-TabNameTwo}</a> <a href="#">{lang-TabNameThree}</a> </div> in Admin some sort of table like this with translation for each language we create. Varialbe ENG DEU POL TabNameThree this is tab one dies ist einer Tab To jest jedna zakladka Or there is totaly other easy way that im not aware of ? Cheers Paul. Link to comment Share on other sites More sharing options...
diogo Posted February 13, 2014 Share Posted February 13, 2014 I'm a bit confused by the title of the thread... so, you don't want it hardcoded right? What you seem to be asking is very easy with the new multi-language fields http://processwire.com/api/multi-language-support/multi-language-fields/ This post from Phillip and subsequent answers might also be useful for you http://processwire.com/talk/topic/5518-multi-language-site/?p=53784 Link to comment Share on other sites More sharing options...
vxda Posted February 13, 2014 Author Share Posted February 13, 2014 what i mean is to have same solution as : What you seem to be asking is very easy with the new multi-language fields http://processwire.c...anguage-fields/ but for front-end. So u can use variables in your page templates Link to comment Share on other sites More sharing options...
Joss Posted February 14, 2014 Share Posted February 14, 2014 There is no reason that you have to have any hard coded text at all really - if you are creating tabs, for instance, you can have the tab headers as fields, either generated by the page that is supplying the pane content or, if you are using them more globally, from some sort of global settings page. Then you can use multi-language fields quite happily. 1 Link to comment Share on other sites More sharing options...
interrobang Posted February 14, 2014 Share Posted February 14, 2014 I think vxda is asking about the built-in gettext-like translatable strings in template files: http://processwire.com/api/multi-language-support/code-i18n/ 1 Link to comment Share on other sites More sharing options...
vxda Posted February 15, 2014 Author Share Posted February 15, 2014 I think vxda is asking about the built-in gettext-like translatable strings in template files Exacly ! thank you Link to comment Share on other sites More sharing options...
vxda Posted February 17, 2014 Author Share Posted February 17, 2014 One thing is not working for me dunno why, in API docs i see this should work: $out = __("It's time for you \nto get to the party."); // good but it seams not, here is my code: <h2><?php echo __('Safe \nplastic surgery') ?></h2> Any tips ? Link to comment Share on other sites More sharing options...
Wanze Posted February 17, 2014 Share Posted February 17, 2014 You need double quotes "". Also I guess the new line is visible when translating the string in the Pw admin. To get a new line in html, you need the br tag: <h2><?php echo nl2br(__("first line\nsecond line"));?></h2> 2 Link to comment Share on other sites More sharing options...
kixe Posted March 19, 2014 Share Posted March 19, 2014 <h2><?php echo __('Safe \nplastic surgery') ?></h2> Cannot reproduce this. Example works in Language Translator/ Language Translator Plus You can use both (Single and Double quotes) look here: wire/modules/LanguageSupport/LanguageParser.php function parseFile($file) It doesn't work, if you have more than one translatable string in one line ,like <h2><?php echo __('Safe \nplastic surgery') ?></h2><p><?php echo __('2nd string') ?></p> The second string will not appear in the language translator. Its a bug. Maybe Ryan could help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now