On 06/06/2014 08:04 AM, Hamster wrote:
We found out that we have several pages created in a
different language than
the default language in our Wiki. Problem is that those pages are not found
directly when we search for them.
Our default language is "nl", but we also got pages in "en" and pages
which
have no launguage at all.
I want to fix those pages, so I turned Localization back on, added "nl" and
"en" as available languages. Now the "EN" button appears when I am
looking
at the page(s) which are created in English. But I don't see how I can
*change* that page into "nl".
Any help is appreciated!
On a side note, how can I find ALL pages which are not written in Dutch?
("nl")
{{groovy}}
def query = services.query.xwql("").addFilter("language")
query.execute().each( {
if (it[1]!='nl')
println it[0]
})
{{/groovy}}
see
http://extensions.xwiki.org/xwiki/bin/view/Extension/Query+Module
However this also gets you pages that as "user interface" pages for the search,
and proper translation variants, i.e. not the "main document", but a translated
one.
For changing the language I think what you could can do is try to change the document
programatically by something like:
if (doc.getDocument().getDefaultLanguage()=='en') {
doc.getDocument().setDefaultLanguage('nl')
doc.save('changed default locale to nl')
}
However this does maybe not work as expected. If you have a page, and the default
language
is English, and and that page has a translation in Dutch, the above code will set
the locale of the "original" page to Dutch. So you you end up with two pages
with "nl" as locale,
the "original" and the "translation" ... I have not checked what side
effects this has,
but they might be "interesting".
So better only do the above only if the document has no language translations already,
and its content is really Dutch, and it is just labled as "en".
Alternatively you could export the page as *.xar, unzip the result and edit
<defaultLanguage> tag,
zip it up again; and then delete the existing page, and import back the xar.
That might be a bit cumbersome if there are a lot of pages like this,
but it feels a bit "safer" that a script that possibly loops over all your
pages
and does something that might or might not be what you want.
Clemens