How to translate OpenWrt LUCI to Arabic?

Hi ALL !
Simply i want to translate openwrt luci to arabic language, so from where should i start?
Any ideas?!

./applications/luci-app-commands/po/ (and similar)

https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html

There may be some "challenges" in the pages themselves as I didn't immediately recognize any other right-to-left languages.

It's seems easy to translate:

msgid "Unknown system error"
msgstr "Error desconegut del sistema" # i know it's not arabic but just an example

i don't know how to use align:right in the translation!
Now i need to setup openwrt toolchain, but should i use a template to work on it? and from where can i get that?

If you've got a device with enough flash, you should be able to overwrite the files you change and add others directly.

One way to do that without needing to build custom images with every change would be to run an x86 version of OpenWrt in a VM. https://openwrt.org/docs/guide-user/virtualization/virtualbox-vm as one way to do this.

When it comes time to building a router-specific image, the general instructions are at https://openwrt.org/docs/guide-developer/build-system/start

i want to build a package so all can benefit.

1 Like

Once you've got it running on your test system (I'd use a VM if I were doing it), then it can easily be added to the packages and built by all.

https://www.w3.org/TR/html4/struct/dirlang.html may help in rendering the text. I haven't poked around with RTL scripts in ages, so it may be that setting lang may be close enough for current browsers.

Edit: Here's a potentially better reference: https://www.w3.org/International/questions/qa-html-dir

2 Likes

I'm wondering why there's no openwrt ISO image, it will make installation in to vm much easier.

Because an ISO is read-only.

I just forgot that point!

1 Like

Start with cloning LuCI using git clone https://github.com/openwrt/luci.git. Within the cloned repository, run ./build/i18n-add-language.sh "ar". The ar string here selects the Arabic macrolanguage.

The script above will initialize a number of untranslated *.po files which you can then start to translate. I suggest Poedit for filling out these files, but any text editor will do the job.

The most important files to translate are base.po, opkg.po and firewall.po as these are strings for components installed by default when selecting LuCI.

To test your translation progress without recompiling packages and reinstalling them all the time, you can manually convert the plaintext *.po files to *.lmo files used by LuCI by using the po2lmo utility.

To compile po2lmo run make -C modules/luci-base/src/ po2lmo in the cloned LuCI sources.

To convert a *.po file, use the po2lmo input.po output.lmo command, e.g. ./modules/luci-base/src/po2lmo modules/luci-base/po/ar/base.po /tmp/base.ar.lmo to convert the arabic base translations.

SCP the resulting /tmp/base.ar.lmo file to /usr/lib/lua/luci/i18n/base.ar.lmo on your router and register the arabic language once by adding the appropriate entries to /etc/config/luci:

uci set luci.languages.ar='العَرَبِيَّة‎ (Arabic)'
uci set luci.main.lang=ar
uci commit luci

Finally browse the pages in the ui to see if the strings appear properly.

Regarding LTR vs. RTL, this should ideally be handled in CSS. LuCI will add a class name containing the language code to the <html> element, allowing for language specific rules. So try appending the following CSS rule to /www/luci-static/bootstrap/cascade.css:

html[lang="ar"] #maincontent {
    direction: rtl;
}

Don't worry if the CSS file is minified, simply append the rule to the end separated by a blank line.

Once you're done with the base translations, add and commit all the arabic *.po files and open a pull request against https://github.com/openwrt/luci.

3 Likes

many thanks jow for detailed info, that's what i need.
but will the built package can be used on all architectures?

you mean:
uci set luci.main.lang=ar
I'm setting up the virtual machine and openwrt build system, lets see how it will going.
also i want to translate some packages like upnp,ban ip, sqm

Here's an example on how LuCI should look like when the CSS rule is properly applied:

Yes, correct - I fixed the typo.

1 Like

While playing around here I noticed that you need to invert the alignment of the logical left and right CSS classes as well, so you'll need three rules:

html[lang="ar"] #maincontent { direction: rtl; }
html[lang="ar"] .left { text-align: right !important; }
html[lang="ar"] .right { text-align: left !important; }

These three should fix up the majority of LTR/RTL issues, for the rest we need to apply individual fixes to the theme as needed.

2 Likes

@jow @jeff
I'm still translating base.po, but i found a typo in the original english msgid:
Custom flash intervall
it should be:

Custom flash interval

i think it's possible to fix the typo in the /en/base.po ?

how will %q or %d will be treated in arabic, i mean should i keep it like default or change it to "q%"
Dealing with lines like this <abbr title="Domain Name System">DNS</abbr> is somewhat hard!

1 Like

You need to keep the percent-sequences as is, they'll usually get interpolated with other values.

As for the typos, simply keep them for now. They need to be fixed treewide in a coordinated manner.

1 Like