Understanding and setting system wide localization

  • I'm looking for the best way to set localization for programs outside of Kodi. Seems to be a topic that is very good for bursting some brains, because there are tons of paths and files where the setting can/must be stored and every distribution does it differently as well.

    Without much Python knowledge I had a look at the locale addon.

    In short it does the following:

    - copy the files from /usr/share/i18n/locale into the addon directory

    - also the program localedef

    - set a few paths

    - bend the system environment 'I18NPath' there

    - create a compiled version of the language definition

    - store 'LANG' and 'LOCPATH' variables in the file '10-locale.profile' in a profile.d directory under the addon directory.

    And that's where I get stuck: What makes LE look for a profile file in an addon subdirectory? How can the environment variable be set permanently in a readonly system? Or are the settings only loaded when the plugin is running? Do you really need to copy the language definitions and localedef into a writable area?

    Or in short, what would be the best way to permanently store the locale settings?

    To clarify, I don't want to criticize the addon but learn from it.

    Thanks in advance

  • Profile data is always in a users home folder, which LE simplifies by having a single (root) user, and mapped to the persistent /storage area which is writeable. So each time the system boots the profile data is read, and whatever paths and such are needed for locales are set. There are also helper functions in the OS that know to search the binary addon paths for system.d, profile.d, udev.rules.d content etc.

  • Thanks for your answer,

    Quote

    Profile data is always in a users home folder.

    Yes, that's what I had thought. So I would have expected a /storage/.profile file. That's why I don't understand why profile data is also found in some addon subdirectory.

    So would the following work?

    - Create a compiled language file with localedef to any location under /storage

    - Create LANG and LOCPATH in /stoarge/.profile, where LOCPATH points to the folder with the created language file

    Would that be it?

  • Haha, of course. But computers weren't really made to do work for you, but to create additional problems for you ;)

    There is definitely a need for some programs to change locale settings. There are many questions on this topic in this forum.

    The thing about the locale addon is that a lot of people don't even know this addon exists or even know what to look for in the first place. There are also LE forks where Kodi is not the focus or is even banned altogether. So it would be useful for some if the settings weren't hidden, for others if there were a script, for example, that would easily do the job via an ssh connection.

    In the last few days I've been busy adding an additional menu item to the service.libreelec.settings addon, where I think the setting fits well. When thinking about saving the settings, however, I came across the questions I described in the first post.

  • The challenge with locales is .. there are lots of them and the cummulative size of files needed to support a decent number (remembering that we are a Global distro/project) is too large to sensibly embed into a minimialist distro image. The need for non-default locales is persistent but overall not a large volume of requests so we've parked them in an add-on.

  • Yes, I have no problem with that opinion at all.

    But wait, maybe that's the reason for our discussion: in the image I made last week from a normal LE checkout, all language definitions are present under /usr/share/i18n/locale (~5MB, 1MB as tgz). That's why I was wondering why the locale addon brings them again. You seem to think that they are not present in the image.

    But I didn't really wanted to discuss all that ;) The only question that would matter to me is whether the steps I listed are correct and if not, which ones.