Jump to content
Soma

Translation in templates using language module

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

  • Like 2

Share this post


Link to post
Share on other sites

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.

Ryan, despite of I've changed the guest user language to Hungarian, the English site loads by default.

I've all the necessary translataions, I don't know how could I change the default lang to Hungarian.

I need this on the public site, in admin the correct lang is loaded I've set for the admin user.

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.

×
×
  • Create New...