Jump to content


Photo

Translation in templates using language module


  • Please log in to reply
3 replies to this topic

#1 Soma

Soma

    Hero Member

  • Moderators
  • 5,057 posts
  • 3824

  • LocationSH, Switzerland

Posted 27 January 2012 - 10:06 AM

I'm trying to get the a translation to work in the search result template.

I got this:


$searchresult_out .= sprintf(_n("Found %d page matching your query:", "Found %d pages matching your query:", $searchresult_count), $searchresult_count);


And it doesn't show up in the translation edit page. Any ideas?

@somartist | modules created | support me, flattr my work flattr.com


#2 ryan

ryan

    Reiska

  • Administrators
  • 7,810 posts
  • 6603

  • LocationAtlanta, GA

Posted 27 January 2012 - 02:00 PM

You've found a bug. Try putting a space before your '_n' ( and that'll fix it. I should have a proper fix committed here in a couple minutes. Thanks for finding this.

Ryan

#3 Soma

Soma

    Hero Member

  • Moderators
  • 5,057 posts
  • 3824

  • LocationSH, Switzerland

Posted 27 January 2012 - 02:57 PM

Ah ok, thanks Ryan, now it works this way.

Just got some OT question.
1. When installed there's the default language, which is english. When I create a new language let's say german I would name it "de" so I can use it for front-end translation and user/guest language as the url segment /de/somepage. I most of the time use it like this and in the page tree I create /de/ and /en/ for the language pages. Now I recognized that I can't change the name "default" to like "en".

Edit: Damn! What was I thinking... meh... thinking more about it , it makes sense to have "default" as a constant, as otherwise one wouldn't be able to know what the default language name would be :). And for using it in a multilang setup it's just a matter of checking for "default" and set the language path segement to "de" or "en" as the global front end lang var.

2. And another one is I just question myself, what do I do when I want to specify german as default? Ok I guess I can drop the german language json package into the default. And then? Create an english language package for the english version?

@somartist | modules created | support me, flattr my work flattr.com


#4 ryan

ryan

    Reiska

  • Administrators
  • 7,810 posts
  • 6603

  • LocationAtlanta, GA

Posted 27 January 2012 - 04:27 PM

Soma, sounds like you've got it right. If you want the default language to be German, then just throw in the German files into the default language. There's nothing English about the default language except for the name "default" (which you uncovered the reasons for). But if you want to connect the language to a code like "de", then I suggest creating a new field called language_code and adding it to the language template. When you want to select a language, just use "language_code=de" in your selector. When you create your English language as an alternate, you won't need to upload any JSON files for the admin side of PW unless you want to change the English that is already there.

I don't think there's any reason to gravitate towards keeping 'default' as English, unless it really is your site's default language. But if you want to do that for some reason, then you would just edit the 'guest' user account and change guest's language to to be 'de' or whatever you want your site's default language to be.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users