Jump to content

Problem with multi languages


buothz
 Share

Recommended Posts

I have a problem with the language system:

1) I have two languages​​, "Default" and my own "it". What I can do to set "It" as default?

2) For the label, system give text of the label in English only ... how can I do to get the translated one when i click italian flag?

Site is: http://www.cosascegli.it try for example an yacht page, if you need I'll post the code now that I'm at work ...

Thank u in advance.

Link to comment
Share on other sites

Let me search that for you ;)

Default language:

http://processwire.c...fault +language

http://processwire.c...dule/#entry7501

Everything about displaying languages in frontend:

http://processwire.c...anguage-fields/

thank u for the response but i can't solve my problem...

If i visit my site with the end of the url http://www.xxx.it/?language=it i see the right language field, but I u use the session i'll see the english.

code

// LANGUAGES
if($input->get->language) {
 // user clicked on a link to set the language
 $name = $sanitizer->pageName($input->get->language);
 $language = $languages->get($name);
 if($language) $session->language = $language->name;
}
if($session->language) {
 // language is defined in user's session
 $user->language = $languages->get($session->language);
}
$field = $fields->get('anno');
$label = $field->get("label$language");
echo "<li><strong>$label:</strong> $s->anno</li>";
$homepage = $pages->get("/");
   $children = $homepage->children;
   $children->prepend($homepage);

   foreach($children as $child) {
 $class = $child === $page->rootParent ? " class='on'" : '';
 echo "<li><a$class href='{$child->url}'>{$child->title}</a></li>";
   } //fine foreach iniziale

   if ($session->language == 'it') {
 echo '<li><a href="./?language=en"><img src="/img/gb.png" alt="English Language"></a></li>';
   } else {
 echo '<li><a href="./?language=it"><img src="/img/it.png" alt="Italian Language"></a></li>';
   }

try

http://www.cosascegl...acht/azimut-75/ (default language it)

http://www.cosascegl...75/?language=it

$session don't record the selected choice?

How what i can do? Problem is ONLY for NAV and LABEL

thank u...

Link to comment
Share on other sites

Looks ok to me. I can switch language just fine.

no :'(

because if I visit

http://www.cosascegl...acht/azimut-75/ eng

Hull Construction: Fiberglass hull, teak deck and cockpit. Flybridge with teak walkways

now i click the italian's flag

http://www.cosascegl...75/?language=it

Materiale Scafo: Vetroresina, ponte e pozzetto in teak. Camminamenti del flybridge in teak

now i refresh (i loose ?language=it but session lang = it)

http://www.cosascegl...acht/azimut-75/

Hull Construction: Vetroresina, ponte e pozzetto in teak. Camminamenti del flybridge in teak

Hull Construction is not italian label! Italian label is "Materiale Scafo"... where is the problem?

Thank u...

Link to comment
Share on other sites

FOUND THE PROBLEM! O0

if ($session->language == 'it') {
 echo '<li><a href="./?language=en"><img src="/img/gb.png" alt="English Language"></a></li>';
 $language = $languages->get("it");
  } else {
 echo '<li><a href="./?language=it"><img src="/img/it.png" alt="Italian Language"></a></li>';
   }

system loose "$language = $languages->get("it");" i've put it on the head.inc for all the pages...

but the problem of the only eng nav? Some one can help me?

Link to comment
Share on other sites

no, how i can activate it on pw?

Go to site, config.php around line 90, set to true:

/**
* debug: debug mode causes additional info to appear for use during dev and debugging
*
* Under no circumstance should you leave this ON with a live site.
*
*/
$config->debug = false;
  • Like 1
Link to comment
Share on other sites

Ah just posted same time.

You should then do this:

The default would be "". Field labels use "anno1299" where 1299 is the id of the language. The default would be just "anno";

$language = '';
if($input->get->language) {
// user clicked on a link to set the language
 $name = $sanitizer->pageName($input->get->language);
 $language = $languages->get($name);
 if($language) $session->language = $language->name;
}
if($session->language) {
 // language is defined in user's session
 $user->language = $languages->get($session->language);
 $language = $languages->get($session->language);
}

Always remember to try to debug. You can then see errors and warnings you don't see without. Turn it on in the site/config.php

Link to comment
Share on other sites

Go to site, config.php around line 90, set to true:

/**
* debug: debug mode causes additional info to appear for use during dev and debugging
*
* Under no circumstance should you leave this ON with a live site.
*
*/
$config->debug = false;

only alert

"Strict Standards: Declaration of Pdfcomposer::___execute() should be compatible with that of Process::___execute() in /home/mhd-01/www.cosascegli.it/htdocs/site/modules/Pdfcomposer.module on line 3

because i don't use it...

i've always problem of the nav language...

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

×
×
  • Create New...