How to replace a faulty string in the official translation?

Hello,

How can I change the translation or text of some UI strings across XWiki?

We use XWiki in single-language mode (but not English) and some UI strings things are just translated badly in our language. Not wrong per se, but in our dialect they sound not quite right and I’d like to replace them across the whole XWiki instance.

I do not want to mess with the official translation repository (I’m sure other people like those strings just the way they are), so I am looking for a way just to overwrite or change the strings on our local XWiki instance.

I did a string search across all XWiki files and found the strings in question to be located in the “xwiki_db.lobs” file but that is obviously not easily editable.

So how can I overwrite certain UI strings in a way that they are also update-proof in the future?

Thank you very much for your advice.

Hello @johnny,

The easy way is to edit the translations directly in the translation documents. But, you’ll likely get conflicts during upgrades.
But, there is a notion of priority based on the location of the translation, so by using the XWikiPreferences bundle, you’ll take priority over the provided translation, allowing you to customize your translations without suffering from merge issues.

Good morning @mleduc and thanks for your quick response.

You write

The easy way is to edit the translations directly in the translation documents

Where exactly are these “translation documents” that I can edit? As I wrote above, I did a string search across all XWiki files and found the strings in question to be located in the xwiki_db.lobs file but that is obviously not easily editable.
I would love it, if the translation strings were somewhere in an xml file or something that I could directly edit. But where?

As for your alternative solution, I think I do understand the gist of what you’re saying but I am afraid I am entirely unclear on the implementation.
Assume I am running the All-In-One demo XWiki with HSQLDB (so you know the directory structure):

  1. Where exactly do I put the file with the new translation strings that shall take priority over the integrated translation?
  2. How does that file have to be structured?
  3. How do I “register” that file in XWiki so it’s getting used with the higher priority?

I would greatly appreciate it, if you could give a quick, hands-on sample of the process, let’s say, to rename the word Username on the login screen, into “Account name”

Thanks!

The translations are spread around in the wiki, in the form of XWiki.TranslationDocumentClass XObjects (you can list them with the snippet below) or as properties located in jar files (you can’t list them from the wiki afaik).

Listing all translations.

{{velocity wiki="false"}}
#foreach ($entry in $services.query.xwql('select distinct t from Document doc, doc.object(XWiki.TranslationDocumentClass) as t').execute())
* $entry.reference
#end
{{/velocity}}

Those translations from wiki pages can be directly edited from the wiki, using the object editor.

See https://extensions.xwiki.org/xwiki/bin/view/Extension/Localization/#HRegisterawikitranslation for more explanations regarding translations, or https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/InternationalizingApplications

PS: another mean to see all translations keys is to go to https://l10n.xwiki.org/, where most of the extensions should have their translations file registered (of course you can’t edit there as this is shared with everytbody)

Good introducing to XWiki scripting, but you can also simply go to the class page (as in https://mysomain/xwiki/bin/view/XWiki/TranslationDocumentClass) :slight_smile:

1 Like

You could officially introduce a new set of translations on http://l10n.xwiki.org for your locale variant (like there is both pt for portuguese from Portugal pt_BR for Brazilian portuguese), but it’s a lot of work of course compared to just customizing a few of them in an existing variant.