Jump to content

Recommended Posts

Posted

hello forum,

after days of smooth work with pw i'm stuck with what looks like a simple problem at first glance: i cant get date field to output localized german names for months. for example i get "july" instead of "juli" or "october" instead of "oktober".

this is my setup:

- i have german language pack installed

- i use a datetime field with date input format = d-m-Y and date output format = %B %Y

- my config.php has this lines

$config->timezone = 'Europe/Berlin';
setlocale(LC_ALL, 'de_DE');

- my php-code is (where project_commission is the date field)

<?php // pull project list from project pages
 foreach ($page->children("limit=20") as $child) {
 echo "<div class='project teaser'>";
 echo "<h3 class='meta'><a href='{$child->url}'>{$child->project_commission}: {$child->title}</a></h3>
 <p class='summary'>{$child->summary} <a href='{$child->url}' title='{$child->title}'> + Mehr erfahren</a></p>";
 echo "</div>";
 }
?> <!-- /project list -->

i've followed the advise i found here and tried to find a solution here but to no avail ...

trying since two hours to fix it. any help is much appreciated. thank you.

Posted

i got a solution:

edited line 144 of /wire/modules/LanguageSupport/LanguageSupport.modules

$locale = $this->_('de_DE');

but i'm unhappy with hacking the core. does anybody know a more elegant solution?

Posted

This value can be edited in the backend. revert your changes in the module and goto setup/languages and edit your german pack. Click the "translate new file" link at the bottom of the page and use this path: /wire/modules/LanguageSupport/LanguageSupport.module

Now you can edit the locale. Hope this helps. I think the LanguageSupport files should be added to the german language pack too..

  • Like 3
Posted

YOu have to set it in the translation of the language for the LanguageSupport.module

$this->_("C"); actually is a translatable string.

Work pefect.

post-100-0-97155600-1346857377_thumb.png

It's already there but not filled.

Posted

Which brings me to another issue I spotted.

Could someone update the German Language pack and add this locale?

And right above the sortable date format is wrong. To be able to sort dates in the admin, they have to be in the order Y/m/d and not d/m/Y.

Thanks

Posted

Am i correct that when $this->_("C"); is not defined in a language pack it does not fall back to the default locale? Because totoff said he had setlocale in config.php so PW should pick up on that, but apparently it doesn't?

Another thing. I haven't used Language packs and the translator myself and am unfamiliar with it's inner workings but could it be an idea to pass an array to setlocale? This way you can add some common values for a particular language and make it a bit more robust across different platforms (*nix, windows etc.)

setlocale(LC_ALL, array('nl_NL', 'nl_NL.UTF8', 'nld_nld'));
Posted

Could someone update the German Language pack and add this locale?

Done. I assume it's fine to just leave the sortable date format untranslated then?

  • Like 1
Posted

Am i correct that when $this->_("C"); is not defined in a language pack it does not fall back to the default locale? Because totoff said he had setlocale in config.php so PW should pick up on that, but apparently it doesn't?

Another thing. I haven't used Language packs and the translator myself and am unfamiliar with it's inner workings but could it be an idea to pass an array to setlocale? This way you can add some common values for a particular language and make it a bit more robust across different platforms (*nix, windows etc.)

setlocale(LC_ALL, array('nl_NL', 'nl_NL.UTF8', 'nld_nld'));

If not defined it will take the default. Default is english in PW. If you set something in config.php doesn't make it the default as it doesn't have language context there, anyway it will get overwritten by the PW language functions.

You can the locale in the translation file ProcessLanguage.module for the particular language, which makes sense.

Done. I assume it's fine to just leave the sortable date format untranslated then?

Thank you for updating it! Yes that should be ok.

  • Like 2
Posted (edited)

Hello forum,

unfortunately I still have weird problems with the date field localization.

Following the instructions here, I set up the language in the admin area (see screenshot) and got German month names in the frontend. But each time I log off from admin area and close the browser this setting is reset to English. After each working day I have to open the language setting again in admin area and hit save to get back to German month names in the frontend. Obviously, this is not the intended behavior ...

Any suggestions anybody?

EDIT: it resets to English as soon as I log out from admin. No need to close the broweser.

post-625-0-82505300-1347011171_thumb.png

Edited by totoff
Posted

I can reproduce, but don't think you have to go save it again... it's more that when you're logged in it works because your admin user has german and when you logout you're as "guest" user looking at frontend. You could make the guest user use german and it should work.

What setup have you got here? If you have only german (one frontend language) you could use the "default" as the german and drop language pack there as the default. Then no need to change anything.

Posted

ok, right, making the guest german works.

i'm new to pw and was unaware of this "per user" setting. however, does this mean i don't need the language pack at all if i have only a german site? could you kindly direct me to the correct setup?

Posted

I haven't done any language packs or multi-lang myself but could you not set the (front end)language in a piece of template code that is included on every page?

$user->language = $languages->get("insert_corrrect_lang_name");
Posted

ok, right, making the guest german works.

i'm new to pw and was unaware of this "per user" setting. however, does this mean i don't need the language pack at all if i have only a german site? could you kindly direct me to the correct setup?

Do you want the back-end in German? No?

Is it only about displaying localized dates in the front-end? Yes

Just disable all multilang support and lang packs and do a setlocale in config.php

Without the multilang stuff the setting should work (i use it all the time to make Dutch week and month names.)

ps have you read http://processwire.com/api/multi-language-support/ ? It gives good overview.

Posted

so i understand there is no way to set the default timezone for your site in the admin area as it is usual with other cms? right? or do i oversee something?

Posted

here is, what i understand: i set the timezone in config.php (see my first post). but if work with a language pack, either because i want a localized admin or because i'm running a multi-language site, i need do assign default languages on a per user-basis in the admin area. otherwise it will default to english.

am i right?

Posted

Yes. But per user is mainly for the admin, on a multilang website you dynamicly set the guest language and together with a language switch.

Posted

so i understand there is no way to set the default timezone for your site in the admin area as it is usual with other cms? right? or do i oversee something?

Not that i'm aware of, and i don't any reason you'd want to have it as a setting in the admin.

config.php has a setting you can easily make.

$config->timezone = 'Europe/Berlin';

add the setlocale and your ready to go.

Posted

In all seriousness, you wouldn't want support tickets without some sort of paid support system otherwise you end up answering the same old questions but just behind closed doors where nobody can see them.

Business Class support isn't a bad idea though for folks who are making a living off building websites and need that level of support.

Posted

You take it too serious Pete! ... ;) I meant more because there's like 3-4 people responding at same time and cross over. :D

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
×
×
  • Create New...