5.2 - Localization, overwrite locale from content

I’m setting up a Norwegian site. On that site I have the usual “Landing Page” content-type, which is supported by my one Page Template.

I create a Content of the type “Landing Page” and name it “In English” and write English text on it. All is good! But now, one Part that was used on the Norwegian pages needs to be put also on this English page. So I set “Language” to “English” under Settings on my content, and drag the Part in. I then implement localization.

Localization works very good. I test it by changing language on the Site. However, I can’t have the Site be all Norwegian while this one content is in English without doing a lot of hacking in my controller.

Feature Request: Make locale on content overwrite the sites locale!


Bobby, Are you creating both Norwegian and english pages within a single site in this case?

Anyway, you can control this yourselves in your localization code by always passing The contextual page’s language to the localize method. Unsure if it is hard to Get that info though?

1 Like

Yes. The Site is Norwegian, but this one page is in English. Possibly with 1-2 sub-pages. On these pages I need a Part but it has a lot of code so I don’t want to duplicate it for english.

It looks hard to get current locale. I tried outputting portal.getComponent, getSite, and getContent, and couldn’t find any locale-data anywhere. Any other options?

It’s cool if I can solve it by sending extra data in, but I kind of expect localization to behave like in 4.7 where you can have minimal code to get localization up. No need to put extra code in your controller and in each localization-call.

1 Like

I understand The requirement, but the use case is actually more tricky - especially if you think about user generated content. What should happen there?

Did you try to create an english subsite?

Sounds like a very complex and heavy solution for a simple thing if I have to create a new site for just one page. That will give me URL problems? Also problems to get menu name dynamically from code? How about Page Templates for that new site, do I need to set them up double for this?

Let content locale overwrite site locale. Then user generated content wouldn’t be a problem. Just like in 4.7.

Or at least give me the locale in one of the portal.get-functions. As of now I can’t tell in my code what language I’m on, unless I hard code content ID into the controller.

So, you want localization in your site to be in chinese if a post was made by a user in that language?
However, the language should be accessible, are you not getting that in the content JSON?

Ah, ofc not, I miss-understood that question. But with user created content they should just be created with page language set. If I write in an English forum but write in Swedish that shouldn’t change anything. Only Site or Content locale that is set from admin manually should change locale.

Nope, can’t find it when outputting all data from portal.getComponent, getContent, and getSite. No “locale” info to be seen =(

If The language property is Missing - we’ll fix it. However, I think I have an idea - if we also add a locale property, that can be used by rendering engine…

1 Like

You can set language on the site and the content, but then you can’t see what was set in the JSON that is returned from content.get. By the way, Bobby, you can see the user-agent locale in the request object, but that doesn’t help here, I guess.

language property is now part of the 5.3 release, we’re also investigating adding a “locale/region” setting for each content - so you can have content in one language, and localization for phrases in another. For 6.0 you will also be able to make your own custom localization lib…