From: Banana Date: Sat, 20 Apr 2024 09:44:30 +0000 (+0200) Subject: i18n key reuse now working. Needed a prefix X-Git-Tag: 1.7~10 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=f5402d1775ccd752383b75cf94ca51ff34b29bac;p=bibliotheca-php.git i18n key reuse now working. Needed a prefix Signed-off-by: Banana --- diff --git a/documentation/tools.md b/documentation/tools.md index 4af3bf8..17d3433 100644 --- a/documentation/tools.md +++ b/documentation/tools.md @@ -7,6 +7,7 @@ and change name, description and action. The other settings can be left as they Filenames are `tool-ACTION.html|php` A optional configuration file `config/config-ACTION.php` A documentation is a must. +Add needed translation keys into eng.ini as a minimum. As a base the provided imdbweb parse is already included. It makes it possible to search for a movie within https://www.imdb.com and let you pick with information should be saved into the entry. diff --git a/webclient/i18n/eng.ini b/webclient/i18n/eng.ini index 4bffcd0..e66616c 100644 --- a/webclient/i18n/eng.ini +++ b/webclient/i18n/eng.ini @@ -114,10 +114,10 @@ managecol.input.combinedsearch.howto = "This could take some time to complete, d managecol.input.defaultsearchfield = "Default global search field" managecol.input.defaultsort = "Default sort field" managecol.input.defaultsortorder = "Default sort order" -managecol.input.delete = global.delete +managecol.input.delete = reuse.global.delete managecol.input.delete.howto = "Warning: This will delete ALL the data in this collection!" -managecol.input.description = global.description -managecol.input.name = global.name +managecol.input.description = reuse.global.description +managecol.input.name = reuse.global.name managecol.input.name.placeholder = "Unique name. No special chars." managecol.input.overwriterights = "Overwrite existing rights" managecol.input.overwriterights.howto = "Warning: This will overwrite existing entry rights (user, group, rights) with the ones from the collection!" @@ -141,9 +141,9 @@ manageentry.message.noTitle = "Entry has no value in title field." manageentry.message.viewNewEntry = "View your new entry" manageentry.possibleduplicate = "Possible duplicate" manageentry.select.bulkedit = "Select bulk edit option" -manageentry.select.bulkedit.add = global.add -manageentry.select.bulkedit.clear = global.clear -manageentry.select.bulkedit.replace = global.replace +manageentry.select.bulkedit.add = reuse.global.add +manageentry.select.bulkedit.clear = reuse.global.clear +manageentry.select.bulkedit.replace = reuse.global.replace manageentry.updateentry = "Update an entry in:" manageentry.viewentry = "View entry" @@ -157,17 +157,17 @@ managefields.message.provideValidFields = "Please provide valid fields." managegroups.addormodify = "Add or modify a group" managegroups.availablegroups = "Available groups" managegroups.groupmanagement = "Group management" -managegroups.input.delete = global.delete +managegroups.input.delete = reuse.global.delete managegroups.input.delete.howto = "Warning: Content owned by this group will not be deleted and thus only manageable by admin!
Right now don't do this. Only if you are sure there is no usage of this group." -managegroups.input.description = global.description -managegroups.input.name = global.name -managegroups.input.save = global.save +managegroups.input.description = reuse.global.description +managegroups.input.name = reuse.global.name +managegroups.input.save = reuse.global.save managegroups.message.couldNotBeCreated = "Group could not be created." managegroups.message.couldNotBeDelete = "Group could not be deleted." managegroups.message.couldNotBeUpdated = "Group could not be updated. Either wrong input or duplicate group name" managegroups.message.missingName = "Provide name and description." -managetags.delete = global.delete +managetags.delete = reuse.global.delete managetags.howto = "The actions are top down. If you choose to move and rename, only move will be executed.
Deletion will remove without recover!
If you rename and input an existing one a move will be done instead.
Tag values are stored how they come and treated that way here (case sensitive). In search they are case insensitive." managetags.managetagsin = "Manage Tags in:" managetags.message.executionError = "Can not execute given options. See logs for more." @@ -179,14 +179,14 @@ managetags.user = "Use" manageuser.addormodify = "Add or modify a user" manageuser.availableusers = "Available users" -manageuser.created = global.created +manageuser.created = reuse.global.created manageuser.groups = "Group(s)" manageuser.input.addgroups = "Additional groups" manageuser.input.apitoken = "Create API Token" manageuser.input.apitoken.current = "Current Token:" manageuser.input.apitoken.valid = "Valid until:" manageuser.input.canloging = "Can login" -manageuser.input.delete = global.delete +manageuser.input.delete = reuse.global.delete manageuser.input.delete.howto = "Warning: Content owned by this user will not be deleted and thus only manageable by admin!
Better disable the user if there is content." manageuser.input.maingroup = "Main group" manageuser.message.couldNotBeCreated = "User could not be created." @@ -202,21 +202,21 @@ message.headline.success = "Success" message.headline.warning = "Warning" menu.manage = "Manage" -menu.manage.add = global.add -menu.manage.collections = global.collections +menu.manage.add = reuse.global.add +menu.manage.collections = reuse.global.collections menu.manage.groups = "Groups" menu.manage.profile = "Profile" -menu.manage.tags = global.tags +menu.manage.tags = reuse.global.tags menu.manage.users = "Users" -menu.search = global.search +menu.search = reuse.global.search menu.search.advanced = "Advanced" menu.search.enter = "Press enter to search" menu.search.within = "Search within the default search field" menu.show = "Show" -menu.show.collections = global.collections +menu.show.collections = reuse.global.collections menu.show.dashboard = "Dashboard" menu.show.sysinfo = "System Information" -menu.show.tags = global.tags +menu.show.tags = reuse.global.tags pagination.gotopage = "Goto page" pagination.next = "next" @@ -225,8 +225,8 @@ pagination.select.sort.default = "Default" pagination.select.sort.latest = "Latest" profile.input.addgroups = "Additional groups" -profile.input.apitoken.current = manageuser.input.apitoken.current -profile.input.apitoken.valid = manageuser.input.apitoken.valid +profile.input.apitoken.current = reuse.manageuser.input.apitoken.current +profile.input.apitoken.valid = reuse.manageuser.input.apitoken.valid profile.input.createtoken = "Create API Token" profile.input.maingroup = "Main group" profile.message.couldNotBeUpdated = "Your profile could not be updated." @@ -234,12 +234,12 @@ profile.yourprofile = "Manage your profile" sysinfo.headline.sysinfo = "System information" sysinfo.th.collection = "Collection" -sysinfo.th.created = global.created +sysinfo.th.created = reuse.global.created sysinfo.th.dbusage = "DB Usage" -sysinfo.th.description = global.description +sysinfo.th.description = reuse.global.description sysinfo.th.diskusage = "Disk Usage" sysinfo.th.entries = "Entries" -sysinfo.th.tags = global.tags +sysinfo.th.tags = reuse.global.tags sysfield.actors = "Actors" sysfield.artist = "Artist" @@ -275,5 +275,22 @@ sysfield.missingtemplate = "Missing template for:" tags.headline.tagsfor = "Tags for:" +tool.gameinfo = "This is a collection of websites which provide different kind of information about games." +tool.googlebooks.save = reuse.global.save +tool.googlebooks.search = reuse.global.search +tool.googlebooks.searchIsbn = "Search ISBN" +tool.googlebooks.select = reuse.global.none tool.headline.using = "Using %s with collection: %s" +tool.imdb.save = reuse.global.save +tool.imdb.search = reuse.global.search +tool.imdb.select.none = reuse.global.none +tool.limitations = "Limitations" +tool.limitations.override = "Data will be overwritten" tool.message.missingFiles = "Required tool files can not be found." +tool.music.input.albumTitle = "Album/Title" +tool.music.input.artist = "Artist" +tool.music.limitations.override = "Data will be overwritten; No wildcardsearch or partial words." +tool.music.save = reuse.global.save +tool.music.search = reuse.global.search +tool.music.select = "Select" +tool.music.select.none = reuse.global.none diff --git a/webclient/lib/i18n.class.php b/webclient/lib/i18n.class.php index 4dfeb56..b2f3702 100644 --- a/webclient/lib/i18n.class.php +++ b/webclient/lib/i18n.class.php @@ -34,10 +34,21 @@ class I18n { */ private array $_langData = array(); + /** + * @var array The fallback lang data. + */ + private array $_langDataFallback = array(); + /** * Translation constructor. */ public function __construct() { + // load fallback + $this->_langDataFallback = parse_ini_file(PATH_ABSOLUTE.'/i18n/eng.ini'); + if(!$this->_langDataFallback) { + Summoner::sysLog('[ERROR] Missing fallback language file!'); + } + if(defined('FRONTEND_LANGUAGE')) { $this->_iso3 = FRONTEND_LANGUAGE['iso3']; $this->_iso2 = FRONTEND_LANGUAGE['iso2']; @@ -50,11 +61,7 @@ class I18n { } } else { - $_langFile = PATH_ABSOLUTE.'/i18n/'.$this->_iso3.'.ini'; - $_langData = parse_ini_file($_langFile); - if($_langData !== false) { - $this->_langData = $_langData; - } + $this->_langData = $this->_langDataFallback; } } @@ -72,19 +79,27 @@ class I18n { */ public function t(string $key, mixed $replace=''): string { $ret = $key; + $_langWorkWith = $this->_langData; if(isset($this->_langData[$key])) { $ret = $this->_langData[$key]; - // the value is another key - if(!str_contains($ret, '"') && str_contains($ret, ".") && isset($this->_langData[$ret])) { - $ret = $this->_langData[$ret]; + } elseif(!DEBUG && isset($this->_langDataFallback[$key])) { + $ret = $this->_langDataFallback[$key]; + $_langWorkWith = $this->_langDataFallback; + } + + // the value is another key + if(str_starts_with($ret, "reuse.")) { + $_ret = str_replace("reuse.","",$ret); + if(isset($_langWorkWith[$_ret])) { + $ret = $_langWorkWith[$_ret]; } + } - if(!empty($replace)) { - if(is_array($replace)) { - $ret = vsprintf($ret, $replace); - } else { - $ret = sprintf($ret, $replace); - } + if(!empty($replace)) { + if(is_array($replace)) { + $ret = vsprintf($ret, $replace); + } else { + $ret = sprintf($ret, $replace); } } return $ret; diff --git a/webclient/view/default/tool/tool-gameinfo.html b/webclient/view/default/tool/tool-gameinfo.html index fc9e7b2..f42f6ac 100644 --- a/webclient/view/default/tool/tool-gameinfo.html +++ b/webclient/view/default/tool/tool-gameinfo.html @@ -1,4 +1,4 @@ -

This is a collection of websites which provide different kind of information about games.

+

t('tool.gameinfo');?>