How do I change or set a language on a page?

Hello all,

So I have my wiki configured to only allow 1 language, English. However, some pages don’t seem to be getting any language assigned at all. These are normal wiki pages without any special code or scripting.

How do I change the page language of an existing page?

I’m hoping I can do this to my templates as I believe these are the root cause. Then update the existing pages with a script or something.

Thanks,
Ben

So you mean the <defaultLanguage> field is empty in the XML representation of the page? For example if I go to http://playground.xwiki.org/xwiki/bin/view/Main/WebHome?xpage=xml I can see <defaultLanguage>en</defaultLanguage>.

At the API level there’s a XWikiDocument#setDefaultLocale(Locale locale) API.

Also I’ve checked and it seems that this field is set when a page is edited for the 1st time. I can see the following in the Edit Action: https://github.com/xwiki/xwiki-platform/blob/a91776de0b7bd2b851e56b0cc6bb8c78be2e7bdb/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/EditAction.java#L140. This indicates IMO that those pages you mention have been created programmatically and no default language has been set for them.

So yes you can use XWikiDocument#setDefaultLocale(Locale locale) or XWikiDocument#setDefaultLanguage(String language) (Deprecated) to set a default language.

There’s no UI to set the default language AFAIK.

Note that this requires PR since there’s currently no API to set the language in the Document class… We need to fix this.

Note: another user reported https://jira.xwiki.org/browse/XWIKI-15159 today :wink:

@Enygma also pointed me to http://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/PageEditing#HDefaultLanguage

Thanks for your responses Vincent and sorry for the late reply.

I’ve checked a few things and it seems something is overriding the default language as set under the administration panel. Is there a setting in the config files I should be aware of?

I turned on multilingual support as shown below,
language

And then whenever I create a page the right hand panel has a blank default language:
Capturefgsfgd

I tried checking the xml as you suggested but my wiki instance doesn’t seem to like it, my browser just hangs. Note that most of my pages are terminal, but did try with Main/WebHome and got the same problem. Any idea what might cause this?