mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-27 20:56:55 +00:00
commit
d03d9cdd6f
2
packages/addons/service/locale/changelog.txt
Normal file
2
packages/addons/service/locale/changelog.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
100:
|
||||||
|
- Initial add-on
|
BIN
packages/addons/service/locale/icon/icon.png
Normal file
BIN
packages/addons/service/locale/icon/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
61
packages/addons/service/locale/package.mk
Normal file
61
packages/addons/service/locale/package.mk
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
################################################################################
|
||||||
|
# This file is part of LibreELEC - https://libreelec.tv
|
||||||
|
# Copyright (C) 2017-present Team LibreELEC
|
||||||
|
#
|
||||||
|
# LibreELEC is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# LibreELEC is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
PKG_NAME="locale"
|
||||||
|
PKG_REV="100"
|
||||||
|
PKG_ARCH="any"
|
||||||
|
PKG_DEPENDS_TARGET="toolchain glibc"
|
||||||
|
PKG_SECTION="service"
|
||||||
|
PKG_SHORTDESC="Locale: allows users to set a custom locale to override the POSIX default"
|
||||||
|
PKG_LONGDESC="Locale ($PKG_REV) allows users to set a custom locale in the OS to override the POSIX default"
|
||||||
|
|
||||||
|
PKG_IS_ADDON="yes"
|
||||||
|
PKG_ADDON_NAME="Locale"
|
||||||
|
PKG_ADDON_TYPE="xbmc.service"
|
||||||
|
|
||||||
|
make_target() {
|
||||||
|
: # nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
makeinstall_target() {
|
||||||
|
: # nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
addon() {
|
||||||
|
mkdir -p "$ADDON_BUILD/$PKG_ADDON_ID/i18n"
|
||||||
|
cp -PR "$(get_build_dir glibc)/localedata/charmaps" \
|
||||||
|
"$(get_build_dir glibc)/localedata/locales" \
|
||||||
|
"$ADDON_BUILD/$PKG_ADDON_ID/i18n"
|
||||||
|
|
||||||
|
mkdir -p "$ADDON_BUILD/$PKG_ADDON_ID/locpath"
|
||||||
|
|
||||||
|
cp -PR $PKG_DIR/resources $ADDON_BUILD/$PKG_ADDON_ID
|
||||||
|
|
||||||
|
locales=""
|
||||||
|
for p in "$ADDON_BUILD/$PKG_ADDON_ID/i18n/locales"/*; do
|
||||||
|
l="$(basename $p)"
|
||||||
|
if [ "$l" = "POSIX" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
locales="$locales|$l"
|
||||||
|
done
|
||||||
|
locales="${locales:1}"
|
||||||
|
|
||||||
|
sed -e "s/@LOCALES@/$locales/" \
|
||||||
|
-i $ADDON_BUILD/$PKG_ADDON_ID/resources/settings.xml
|
||||||
|
}
|
7
packages/addons/service/locale/resources/settings.xml
Normal file
7
packages/addons/service/locale/resources/settings.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||||
|
<settings>
|
||||||
|
<category label="30000">
|
||||||
|
<setting label="30001" id="charmap" type="select" default="UTF-8" values="UTF-8" enable="false" />
|
||||||
|
<setting label="30002" id="locale" type="select" default="en_GB" values="@LOCALES@" />
|
||||||
|
</category>
|
||||||
|
</settings>
|
74
packages/addons/service/locale/source/default.py
Normal file
74
packages/addons/service/locale/source/default.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
################################################################################
|
||||||
|
# This file is part of LibreELEC - https://libreelec.tv
|
||||||
|
# Copyright (C) 2017-present Team LibreELEC
|
||||||
|
#
|
||||||
|
# LibreELEC is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# LibreELEC is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import xbmc
|
||||||
|
import xbmcaddon
|
||||||
|
import xbmcgui
|
||||||
|
|
||||||
|
|
||||||
|
class Monitor(xbmc.Monitor):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
xbmc.Monitor.__init__(self)
|
||||||
|
self.setLocale()
|
||||||
|
|
||||||
|
def onSettingsChanged(self):
|
||||||
|
self.setLocale()
|
||||||
|
|
||||||
|
def setLocale(self):
|
||||||
|
addon = xbmcaddon.Addon()
|
||||||
|
|
||||||
|
charmap = addon.getSetting('charmap')
|
||||||
|
locale = addon.getSetting('locale')
|
||||||
|
lang = locale + '.' + charmap
|
||||||
|
|
||||||
|
path = addon.getAddonInfo('path')
|
||||||
|
i18npath = os.path.join(path, 'i18n')
|
||||||
|
locpath = os.path.join(path, 'locpath')
|
||||||
|
localepath = os.path.join(locpath, lang)
|
||||||
|
profiled = os.path.join(path, 'profile.d')
|
||||||
|
profile = os.path.join(profiled, '10-locale.profile')
|
||||||
|
|
||||||
|
strings = addon.getLocalizedString
|
||||||
|
|
||||||
|
if os.path.isdir(locpath) == False:
|
||||||
|
os.makedirs(locpath)
|
||||||
|
|
||||||
|
if os.path.isdir(localepath) == False:
|
||||||
|
os.environ['I18NPATH'] = i18npath
|
||||||
|
subprocess.call(['localedef', '-f', charmap, '-i', locale, localepath])
|
||||||
|
|
||||||
|
if os.path.isdir(profiled) == False:
|
||||||
|
os.makedirs(profiled)
|
||||||
|
|
||||||
|
file = open(profile, 'w')
|
||||||
|
file.write('export LANG="' + lang + '"\n')
|
||||||
|
file.write('export LOCPATH="' + locpath + '"\n')
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
current = os.environ.get('LANG', '')
|
||||||
|
if lang != current:
|
||||||
|
if xbmcgui.Dialog().yesno('Locale', strings(30003).format(current, lang)
|
||||||
|
) == True:
|
||||||
|
xbmc.restart()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
Monitor().waitForAbort()
|
@ -0,0 +1,19 @@
|
|||||||
|
# Kodi Media Center language file
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30000"
|
||||||
|
msgid "Configuration"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30001"
|
||||||
|
msgid "Charmap"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30002"
|
||||||
|
msgid "Locale"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30003"
|
||||||
|
msgid "Locale changed from {} to {}. Please reboot to apply globally."
|
||||||
|
msgstr ""
|
@ -0,0 +1,4 @@
|
|||||||
|
<settings>
|
||||||
|
<setting id="charmap" value="UTF-8" />
|
||||||
|
<setting id="locale" value="en_GB" />
|
||||||
|
</settings>
|
Loading…
x
Reference in New Issue
Block a user