How to apply language change to newly added menu in LuCI

I am a newbie to openwrt, I am able to bring in a new menu in LuCI by following https://openwrt.org/docs/guide-developer/luci

I enabled spanish language support by installing 'luci-i18n-es' package and it is reflected in LuCI under "System --> Sytem --> Language and Style" list.
When I select 'spanish' language and apply the configuration, I could see the Status, System, Services and Networ menus are translated.
How can I bring in the language translation to the newly added menu in LuCI based as per the selected language settings?

luci-i18n-base-es

should do the job, I think

HTH

luci-i18n-base-es is already installed on the unit, but it is not doing the job for the newly added menu.

root@XXYYY:/usr/lib/lua/luci/# opkg list | grep luci-i18n-base
luci-i18n-base-en - git-21.044.30835-34e0d65-1
luci-i18n-base-es - git-21.044.30835-34e0d65-1
luci-i18n-base-pt - git-21.044.30835-34e0d65-1
root@XXYYY:/usr/lib/lua/luci/#

If "newly added menu" you mean you wrote code to add a new menu, you also need to write the translations for it and anything else you created in the translation file. Translation is not automatic.

It should look like this https://github.com/openwrt/luci/blob/master/modules/luci-base/po/es/base.po but I don't know exactly where it is in a device when it is running.

Thanks for the details. Yes, I wrote code to add a new menu and the language translation is not working.
I found another similar topic https://forum.archive.openwrt.org/viewtopic.php?id=62170

In the LuCI source tree, run the following commands, replace "yourapp" as needed.

  • mkdir -p applications/luci-app-yourapp/po/templates
  • ./build/i18n-scan.pl applications/luci-app-yourapp/ > applications/luci-app-yourapp/po/templates/yourapp.pot
  • ./build/i18n-add-language.sh es

You'll then find a file called applications/luci-app-yourapp/po/es/yourapp.po which you can translate using utilities like poedit.

To test the translation on-target, there's two solutions:

Variant 1 (using OpenWrt buildroot or SDK and your customized luci.git as feed)

  • Rebuild the package: make package/luci-app-yourapp/{clean,compile}in the OpenWrt buildroot - this should also rebuild the hidden luci-i18n-yourapp-es package
  • Transfer the .ipk archive from bin/packages/*/luci/luci-i18n-yourapp-es*.ipk to your target device and install it with opkg or upload it via the LuCI software page

Variant 2 (just build the binary lmo file without OpenWrt buildroot or SDK)

  • Compile the po2lmo utility: make -C ./modules/luci-base/src po2lmo (mind the space, execute in the LuCI sourcetree topdir)
  • Run ./modules/luci-base/src/po2lmo ./applications/luci-app-yourapp/po/es/yourapp.po /tmp/yourapp.es.lmo
  • Transfer /tmp/yourapp.es.lmo to /usr/lib/lua/luci/i18n/yourapp.es.lmo on the target device
3 Likes

@jow
Thank you very much for the details. I am able to make the language translation to work as expected for the newly added LuCI modules/applications.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.