mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
lang: Better handle duplicate translation target matches
For example, LANG_TIME_SET_BUTTON has these: *: none aigoerosq,erosqnative,gogearsa9200,samsungyh*: "PLAY = Set" gigabeat*,iaudiom5,iaudiox5,ipod*,iriverh10,iriverh10_5gb,mrobe100,sansac200*,sansaclip*,sansaconnect,sansae200*,sansafuze*: "SELECT = Set" iriverh100,iriverh120,iriverh300: "NAVI = Set" mpiohd300: "ENTER = Set" mrobe500: "HEART = Set" rtc: "ON = Set" vibe500: "OK = Set" But all of these players will match their name _and_ the generic 'rtc' feature that enables use of this phrase. The language tooling always used the final match in the list, so this resulted in most devices showing the generic (and incorrect) 'ON = Set" instead of the device-specific strings. This patch changes the behavior so that only a match with the device model itself can override the previously used string. Change-Id: I93ee11b1e4925c39edaecdcbc13ccc51ed176a45
This commit is contained in:
parent
c08bbaac49
commit
f38109f8ed
4 changed files with 38 additions and 65 deletions
|
@ -17,9 +17,6 @@
|
||||||
# This is the master of the language files. This is the original, the one with
|
# This is the master of the language files. This is the original, the one with
|
||||||
# all the existing strings Rockbox features.
|
# all the existing strings Rockbox features.
|
||||||
#
|
#
|
||||||
# The target names used for target-specific strings are set in the ARCHOS
|
|
||||||
# variable in the root Makefile
|
|
||||||
#
|
|
||||||
# *WARNING*
|
# *WARNING*
|
||||||
#
|
#
|
||||||
# If you want to add a new string, add it to the end of this file!
|
# If you want to add a new string, add it to the end of this file!
|
||||||
|
@ -31,8 +28,6 @@
|
||||||
# If you re-order things or remove entries, you must bump the binary language
|
# If you re-order things or remove entries, you must bump the binary language
|
||||||
# file version number in both the 'genlang' tool and the language loader code.
|
# file version number in both the 'genlang' tool and the language loader code.
|
||||||
#
|
#
|
||||||
# The "voice" entry contains how we want the speech UI to pronounce the phrase.
|
|
||||||
#
|
|
||||||
# Since this file is both the master for the language system, as well as the
|
# Since this file is both the master for the language system, as well as the
|
||||||
# source for generating english strings, make sure that all <source> strings
|
# source for generating english strings, make sure that all <source> strings
|
||||||
# are *identical* to the <dest> strings within the english.lang file. The
|
# are *identical* to the <dest> strings within the english.lang file. The
|
||||||
|
@ -41,57 +36,34 @@
|
||||||
# used to simply get the full set of english strings for a particular target.
|
# used to simply get the full set of english strings for a particular target.
|
||||||
#
|
#
|
||||||
# All phrases have a default string like: *: "default" that will be used if no
|
# All phrases have a default string like: *: "default" that will be used if no
|
||||||
# other string matches for the particular model you build the language for. If
|
# other string matches for the particular model you are building for. If
|
||||||
# you want a particular string for the iriver iriverh300 series you'd write it like:
|
# you want a particular string for the a specific target, you would write it like:
|
||||||
# iriverh300: "iriverh300-specific string" (below the default line). If your string isn't
|
# target: "target-specific string" (below the default line). If your string isn't
|
||||||
# used for all targets set the default to none like: *: none (no quotes!) this
|
# used for all targets set the default to none like: *: none (no quotes!) to ensure
|
||||||
# will not include the string for target that will not need it, see
|
# it will not be included for targets that do not need it. See apps/features.txt
|
||||||
# apps/features.txt for available categories that can be used instead of the
|
# for all available target features that can be used instead of or in addition
|
||||||
# target name, for example: swcodec: "swcodec-specific string".
|
# to the target name.
|
||||||
#
|
#
|
||||||
# The target names used are picked from the configure script and are set in the
|
# The target names used are picked from the configure script and are set in the
|
||||||
# MODELNAME variable in the root makefile. This is an incomplete list:
|
# MODELNAME variable in the root makefile.
|
||||||
# Target Target string
|
#
|
||||||
# iriver
|
# The indidivual entries under the <voice> section of a phrase contain the text
|
||||||
# H100/H110/H115 iriverh100
|
# the speech UI will use to pronounce the phrase. This is usually the same
|
||||||
# H120/H140 iriverh120
|
# as the <dest> section, but there are more limitations. For example, most
|
||||||
# H320/H340 iriverh300
|
# punctuation and strings with C format specifiers are not allowed. If a
|
||||||
# H10 iriverh10
|
# phrase is not intended to be voiced at all, you can use '*: none' under
|
||||||
# iaudio/Cowon
|
# its <voice> section.
|
||||||
# X5 iaudiox5
|
#
|
||||||
# M5 iaudiom5
|
# To validate the contents of a translation, you can use the Rockbox translation
|
||||||
# D2 cowond2*
|
# site at https://translate.rockbox.org. Alternatively, you can use the command-
|
||||||
# ipod
|
# line 'updatelang' tool as follows:
|
||||||
# All iPods ipod*
|
#
|
||||||
# 4G Color/Photo ipodcolor
|
# tools/updatelang apps/lang/english.lang path/to/translation.lang - |less
|
||||||
# Nano ipodnano1g
|
#
|
||||||
# Video (5G) ipodvideo
|
# All problematic areas will be marked with '###'
|
||||||
# 3G ipod3g
|
#
|
||||||
# 4G gray ipod4g
|
####
|
||||||
# mini ipodmini1g
|
# This is the first item, and will be shown when P2STR is passed a NULL pointer
|
||||||
# mini 2G ipodmini2g
|
|
||||||
# Toshiba
|
|
||||||
# All gigabeats gigabeat*
|
|
||||||
# Gigabeat Fxx gigabeatfx
|
|
||||||
# Gigabeat Sxx gigabeats
|
|
||||||
# Sandisk
|
|
||||||
# Sansa E200 sansae200*
|
|
||||||
# Sansa C200 sansac200*
|
|
||||||
# Sansa Fuze sansafuze*
|
|
||||||
# Sansa Clip sansaclip*
|
|
||||||
# Olympus
|
|
||||||
# m:robe 100 mrobe100
|
|
||||||
# m:robe 500 mrobe500
|
|
||||||
# Mpio
|
|
||||||
# HD200 mpiohd200
|
|
||||||
# HD300 mpiohd300
|
|
||||||
# Packard Bell
|
|
||||||
# Vibe 500 vibe500
|
|
||||||
# Philips
|
|
||||||
# GoGear SA9200 gogearsa9200
|
|
||||||
# Samsung
|
|
||||||
# YH820/YH920/YH925 samsungyh*
|
|
||||||
# First item will be shown when P2STR is passed a NULL pointer
|
|
||||||
<phrase>
|
<phrase>
|
||||||
id: LANG_ROCKBOX_TITLE
|
id: LANG_ROCKBOX_TITLE
|
||||||
desc: main menu title
|
desc: main menu title
|
||||||
|
@ -3702,7 +3674,6 @@
|
||||||
</dest>
|
</dest>
|
||||||
<voice>
|
<voice>
|
||||||
*: none
|
*: none
|
||||||
gigabeat*,gogearsa9200,iaudiom5,iaudiox5,ipod*,iriverh10,iriverh100,iriverh10_5gb,iriverh120,iriverh300,mrobe100,rtc,samsungyh*,sansac200*,sansae200*: ""
|
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</phrase>
|
||||||
<phrase>
|
<phrase>
|
||||||
|
@ -3739,7 +3710,6 @@
|
||||||
</dest>
|
</dest>
|
||||||
<voice>
|
<voice>
|
||||||
*: none
|
*: none
|
||||||
gigabeat*,gogearsa9200,iaudiom5,iaudiox5,ipod*,iriverh10,iriverh100,iriverh10_5gb,iriverh120,iriverh300,mrobe100,rtc,samsungyh*,sansac200*,sansae200*: ""
|
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</phrase>
|
||||||
<phrase>
|
<phrase>
|
||||||
|
|
|
@ -37,10 +37,9 @@ $(BUILDDIR)/lang/lang_core.o: $(BUILDDIR)/lang/lang.h $(BUILDDIR)/lang/lang_core
|
||||||
# instead we pretend that genlang create lang_core.c and that lang.c depends from lang.h
|
# instead we pretend that genlang create lang_core.c and that lang.c depends from lang.h
|
||||||
# it will work fine as long as one never manually removes lang.c and not lang.h, and it will avoid
|
# it will work fine as long as one never manually removes lang.c and not lang.h, and it will avoid
|
||||||
# race conditions such as running genlang twice or worse in parallel with other things!
|
# race conditions such as running genlang twice or worse in parallel with other things!
|
||||||
$(BUILDDIR)/lang/lang.h: $(APPSDIR)/lang/$(ENGLISH).lang $(BUILDDIR)/apps/features $(TOOLSDIR)/genlang
|
$(BUILDDIR)/lang/lang.h: $(APPSDIR)/lang/$(ENGLISH).lang $(BUILDDIR)/apps/genlang-features $(TOOLSDIR)/genlang
|
||||||
$(call PRINTS,GEN lang.h)
|
$(call PRINTS,GEN lang.h)
|
||||||
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
|
$(SILENT)$(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(MODELNAME):`cat $(BUILDDIR)/apps/genlang-features` $<
|
||||||
perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(MODELNAME)$$feat $<
|
|
||||||
$(BUILDDIR)/lang/lang_core.c: $(BUILDDIR)/lang/lang.h $(TOOLSDIR)/genlang
|
$(BUILDDIR)/lang/lang_core.c: $(BUILDDIR)/lang/lang.h $(TOOLSDIR)/genlang
|
||||||
|
|
||||||
$(BUILDDIR)/lang_enum.h: $(BUILDDIR)/lang/lang.h $(TOOLSDIR)/genlang
|
$(BUILDDIR)/lang_enum.h: $(BUILDDIR)/lang/lang.h $(TOOLSDIR)/genlang
|
||||||
|
|
|
@ -42,7 +42,7 @@ Usage: genlang [options] <langv2 file>
|
||||||
|
|
||||||
-t=<target>
|
-t=<target>
|
||||||
Specify which target you want the translations/phrases for. Required when
|
Specify which target you want the translations/phrases for. Required when
|
||||||
-b or -p is used.
|
-b, -o, or -p is used.
|
||||||
|
|
||||||
The target can in fact be specified as numerous different strings,
|
The target can in fact be specified as numerous different strings,
|
||||||
separated with colons. This will make genlang to use all the specified
|
separated with colons. This will make genlang to use all the specified
|
||||||
|
@ -103,15 +103,19 @@ if(!$target) {
|
||||||
# discard any duplicates generated for us in the process of constructing the
|
# discard any duplicates generated for us in the process of constructing the
|
||||||
# state machine, so we don't bother to check.
|
# state machine, so we don't bother to check.
|
||||||
my $target_regex = "(?:^|,) *(?:\\*";
|
my $target_regex = "(?:^|,) *(?:\\*";
|
||||||
|
my $model_regex = ""; # This matches the player model only!
|
||||||
foreach my $target_part (split ':', $target) {
|
foreach my $target_part (split ':', $target) {
|
||||||
for (my $c=1; $c<=length $target_part; $c++) {
|
for (my $c=1; $c<=length $target_part; $c++) {
|
||||||
my $partial = substr $target_part, 0, $c;
|
my $partial = substr $target_part, 0, $c;
|
||||||
$target_regex .= "|$partial\\*";
|
$target_regex .= "|$partial\\*";
|
||||||
}
|
}
|
||||||
$target_regex .= "|$target_part";
|
$target_regex .= "|$target_part";
|
||||||
|
$model_regex = $target_regex if (!$model_regex);
|
||||||
}
|
}
|
||||||
$target_regex .= ") *(?:,|\$)";
|
$target_regex .= ") *(?:,|\$)";
|
||||||
$target_regex = qr/$target_regex/;
|
$target_regex = qr/$target_regex/;
|
||||||
|
$model_regex .= ") *(?:,|\$)";
|
||||||
|
$model_regex = qr/$model_regex/;
|
||||||
|
|
||||||
my $binpath = "";
|
my $binpath = "";
|
||||||
if ($binary =~ m|(.*)/[^/]+|) {
|
if ($binary =~ m|(.*)/[^/]+|) {
|
||||||
|
@ -170,7 +174,8 @@ sub parsetarget {
|
||||||
my $string;
|
my $string;
|
||||||
if ($n =~ $target_regex) {
|
if ($n =~ $target_regex) {
|
||||||
$string = $v;
|
$string = $v;
|
||||||
$$strref = $string;
|
# Only override the previously set string if this is a device-specific match
|
||||||
|
$$strref = $string if (!$$strref || $$strref eq 'none' || $n =~ $model_regex);
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,13 +399,12 @@ manual-7zip:
|
||||||
|
|
||||||
ifdef TTS_ENGINE
|
ifdef TTS_ENGINE
|
||||||
|
|
||||||
voice: voicetools $(BUILDDIR)/apps/features
|
voice: voicetools $(BUILDDIR)/apps/genlang-features
|
||||||
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
|
$(SILENT)if [ -z "$$POOL" ] ; then \
|
||||||
if [ -z "$$POOL" ] ; then \
|
|
||||||
export POOL="$(BUILDDIR)/voice-pool" ; \
|
export POOL="$(BUILDDIR)/voice-pool" ; \
|
||||||
fi;\
|
fi;\
|
||||||
mkdir -p $${POOL} ;\
|
mkdir -p $${POOL} ;\
|
||||||
for lang in `echo $(VOICELANGUAGE) |sed "s/,/ /g"`; do $(TOOLSDIR)/voice.pl -V -l=$$lang -t=$(MODELNAME)$$feat -i=$(TARGET_ID) -e="$(ENCODER)" -E="$(ENC_OPTS)" -s=$(TTS_ENGINE) -S="$(TTS_OPTS)"; done
|
for lang in `echo $(VOICELANGUAGE) |sed "s/,/ /g"`; do $(TOOLSDIR)/voice.pl -V -l=$$lang -t=$(MODELNAME):`cat $(BUILDDIR)/apps/genlang-features` -i=$(TARGET_ID) -e="$(ENCODER)" -E="$(ENC_OPTS)" -s=$(TTS_ENGINE) -S="$(TTS_OPTS)"; done
|
||||||
|
|
||||||
talkclips: voicetools
|
talkclips: voicetools
|
||||||
$(SILENT)if [ -z '$(TALKDIR)' ] ; then \
|
$(SILENT)if [ -z '$(TALKDIR)' ] ; then \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue