pwired Posted March 9, 2015 Share Posted March 9, 2015 Hi What is the best way to pull in multi language words. What do I mean by this, we'll let's take for example a form. The words that stand above the entry fields are for example: Your name, Your email address Home address, etc. etc. In multi language that means also Deine Name, Deine Email-Adress, - - - - or Nombre, Direccion de correo, etc. etc. At this moment I setup a field with property multi language and then fill in all the words in all the languages that I need to put above the entry fields of a form. Then thanks to the open flexibility of processwire I can use any php solution to pull the words from the field and output them where I need. I use a simple php explode and then use array elements to output the right words in the right places. Here an example for multi language words in a horizontal menu bar: <?php $temp = $pages->get("/top-navigation/"); $words = $temp->top_navigation; $nav = explode(",", $words); ?> <div class="navbar block"> <a href="<?=$pages->get("/")->url ?>"><?php echo $nav[0]; ?></a> <a href="<?=$pages->get("/mein-weg/")->url ?>"><?php echo $nav[1]; ?></a> <a href="<?=$pages->get("/berufe/")->url ?>"><?php echo $nav[2]; ?></a> <a href="<?=$pages->get("/ausbildungen/")->url ?>"><?php echo $nav[3]; ?></a> <a href="<?=$pages->get("/geistiges/")->url ?>"><?php echo $nav[4]; ?></a> <a href="<?=$pages->get("/heilsitzungen/")->url ?>"><?php echo $nav[5]; ?></a> </div> Now this is working ok but I was wondering how you guys are doing these things and if I am missing a feature in processwire that could do this more easy ? Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 9, 2015 Share Posted March 9, 2015 Most of the time a form or is a one time setup, so I just use the following and translate it with processwires on board language management. <label for="name"><?php echo __("Name"); ?></label> <input name="name" …> For the navigation, why don't you use a simple multilanguage textfield for each page's title? 1 Link to comment Share on other sites More sharing options...
pwired Posted March 9, 2015 Author Share Posted March 9, 2015 Ok thanks, yes I am simply not used to use fields so extensively but it makes sense to use a separate field for each word or menu item. I don't quite follow your code (yet) <?php echo __("Name"); ?> why the long underscore __ and is ("Name") referring to a variable ? Link to comment Share on other sites More sharing options...
arjen Posted March 9, 2015 Share Posted March 9, 2015 This is called "Code Internationalization". There are several ways to do this, also for plurals and context. Read more in the multi language support docs. 2 Link to comment Share on other sites More sharing options...
pwired Posted March 9, 2015 Author Share Posted March 9, 2015 Thanks for the link, will be home in an hour and get into it. 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