Jump to content
totoff

Can't get PW to output German month names

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

thank you interrobang and Soma,

reverted code change and followed your advice. works. thanks again.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

i would be glad to help, but need instruction. how would you do this?

Share this post


Link to post
Share on other sites

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'));

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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");

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Timezone is in the config.php...

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

thanks again for your supprt soma, got it now - i hope ;-)

Share this post


Link to post
Share on other sites

I think you can have german as default by dropping the files into the default language. See and

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By kreativmonkey
      Hi,
      i want to set a date field value by api but i have problems to do so. I think this should be work:
      $page->of(false); $page->expire_date = time(); $page->save(); $page->of(true); but when i look into the field i get not the saved time. The output is always: 30 Nov, -0001 00:00  (timestamp: -62169987208).
      when i echo the time directly after the $page->of(true); than i get the current time but avter reload and output the time bevor $page->of(false); i get the time above!
      do you have any idea whats the problem?
    • By abdus
      I'm trying to build a multilanguage website with Turkish as main and English as alternative language. I replaced hardcoded strings in template files and used built-in translation tools to translate template files. I'm using the functions ProcessWire provides:
      // using __() <?= __("There are no products to display.") ?> // or _x() <html lang="<?= echo _x('en', 'HTML language code'); ?>"> // Both works when I use _main.php When I disable auto including _main.php from config.php file, and move or rename _main.php to something else or use another file (other than  _main.php that comes with site-languages profile) for template specific markups, say markup/products.php like below, translations stop working.
      // config.php, disabled auto append // $config->appendTemplateFile = '_main.php'; // home.php include_once("./_main.php"); wireIncludeFile("./_main.php"); // TRANSLATION WORKS include_once("./_home.php"); // DOESNT WORK wireIncludeFile("markup/_main.php"); include_once("markup/_main.php"); // DOESNT WORK // NOTE: home.php and main.php has the same content, same permissions, same ownership I debugged the issue, and the reason, as ridiculous as it sounds, originates from using file other than _main.php. I searched the forums, google, but this seems like a unique issue. Is there anything I'm missing and how can I fix this, because I can't think of anything else after hours lost trying to find the underlying cause?
      Thanks in advance.
    • By Orkun
      I have set the right Datepicker translation file "/wire/modules/Jquery/JqueryUI/i18n/jquery.ui.datepicker-de.js".
      And change the code from:
      /* German initialisation for the jQuery UI date picker plugin. */ /* Written by Milian Wolff (mail@milianw.de). */ jQuery(function($){ $.datepicker.regional['de'] = { closeText: 'schließen', prevText: '<zurück', nextText: 'Vor>', currentText: 'heute', monthNames: ['Januar','Februar','März','April','Mai','Juni', 'Juli','August','September','Oktober','November','Dezember'], monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun', 'Jul','Aug','Sep','Okt','Nov','Dez'], dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'], dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'], dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'], weekHeader: 'KW', dateFormat: 'dd.mm.yy', firstDay: 1, isRTL: false, showMonthAfterYear: false, yearSuffix: ''}; $.datepicker.setDefaults($.datepicker.regional['de']); }); to:
      /* German initialisation for the jQuery UI date picker plugin. */ /* Written by Milian Wolff (mail@milianw.de). */ jQuery(function($){ $.datepicker.regional['de'] = { closeText: 'schließen', prevText: '<zurück', nextText: 'Vor>', currentText: 'heute', monthNames: ['Januar','Februar','März','April','Mai','Juni', 'Juli','August','September','Oktober','November','Dezember'], monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun', 'Jul','Aug','Sep','Okt','Nov','Dez'], dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'], dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'], dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'], weekHeader: 'KW', dateFormat: 'dd.mm.yy', firstDay: 1, isRTL: false, showMonthAfterYear: false, yearSuffix: ''}; $.datepicker.setDefaults($.datepicker.regional['de']); $.timepicker.regional['de'] = { timeText: 'Uhrzeit', hourText: 'Stunde', minuteText: 'Minute', secondText: 'Sekunde', millisecText: 'Millisekunde', timezoneText: 'Zeitzone', currentText: 'jetzt', closeText: 'schliessen', }; $.timepicker.setDefaults($.timepicker.regional['de']); }); But it only affects the date and not the time. What I'm missing?
    • By EvanFreyer
      Hey there,
      I have a problem with URL Segments and Umlauts in it. I want to grab the a segment of the url and use it as a parameter to find a something in Processwire. The problem is, that if I input an umlaut into the url, processwire immediately throws a 404 error page and I am not able to transform my inputs.
      Is there a way to get around that problem?
      Cheers,
      Evan
    • By MarcC
      I'm testing ProcessWIre's localization features, trying out fields like TextAreaLanguage and PageTitleLanguage. I've got them installed, assigned, and filled out. Now, how do I, for example, make Spanish-language fields show up on the public site for Spanish-language visitors?
      It feels like a bit of a dumb question, but I swear I looked at the docs!
      I thought it might be automatic detection based on a header string or something, but that hasn't worked for me. I don't know exactly what details to look for as this is my first time through. Thanks!
×
×
  • Create New...