Jump to content

From where to pull multi language words


pwired
 Share

Recommended Posts

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

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? 

  • Like 1
Link to comment
Share on other sites

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

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