mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -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
|
||||
# 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*
|
||||
#
|
||||
# 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
|
||||
# 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
|
||||
# source for generating english strings, make sure that all <source> strings
|
||||
# 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.
|
||||
#
|
||||
# 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
|
||||
# you want a particular string for the iriver iriverh300 series you'd write it like:
|
||||
# iriverh300: "iriverh300-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
|
||||
# will not include the string for target that will not need it, see
|
||||
# apps/features.txt for available categories that can be used instead of the
|
||||
# target name, for example: swcodec: "swcodec-specific string".
|
||||
# other string matches for the particular model you are building for. If
|
||||
# you want a particular string for the a specific target, you would write it like:
|
||||
# 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!) to ensure
|
||||
# it will not be included for targets that do not need it. See apps/features.txt
|
||||
# for all available target features that can be used instead of or in addition
|
||||
# to the target name.
|
||||
#
|
||||
# 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:
|
||||
# Target Target string
|
||||
# iriver
|
||||
# H100/H110/H115 iriverh100
|
||||
# H120/H140 iriverh120
|
||||
# H320/H340 iriverh300
|
||||
# H10 iriverh10
|
||||
# iaudio/Cowon
|
||||
# X5 iaudiox5
|
||||
# M5 iaudiom5
|
||||
# D2 cowond2*
|
||||
# ipod
|
||||
# All iPods ipod*
|
||||
# 4G Color/Photo ipodcolor
|
||||
# Nano ipodnano1g
|
||||
# Video (5G) ipodvideo
|
||||
# 3G ipod3g
|
||||
# 4G gray ipod4g
|
||||
# mini ipodmini1g
|
||||
# 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
|
||||
# MODELNAME variable in the root makefile.
|
||||
#
|
||||
# The indidivual entries under the <voice> section of a phrase contain the text
|
||||
# the speech UI will use to pronounce the phrase. This is usually the same
|
||||
# as the <dest> section, but there are more limitations. For example, most
|
||||
# punctuation and strings with C format specifiers are not allowed. If a
|
||||
# phrase is not intended to be voiced at all, you can use '*: none' under
|
||||
# its <voice> section.
|
||||
#
|
||||
# To validate the contents of a translation, you can use the Rockbox translation
|
||||
# site at https://translate.rockbox.org. Alternatively, you can use the command-
|
||||
# line 'updatelang' tool as follows:
|
||||
#
|
||||
# tools/updatelang apps/lang/english.lang path/to/translation.lang - |less
|
||||
#
|
||||
# All problematic areas will be marked with '###'
|
||||
#
|
||||
####
|
||||
# This is the first item, and will be shown when P2STR is passed a NULL pointer
|
||||
<phrase>
|
||||
id: LANG_ROCKBOX_TITLE
|
||||
desc: main menu title
|
||||
|
@ -3702,7 +3674,6 @@
|
|||
</dest>
|
||||
<voice>
|
||||
*: none
|
||||
gigabeat*,gogearsa9200,iaudiom5,iaudiox5,ipod*,iriverh10,iriverh100,iriverh10_5gb,iriverh120,iriverh300,mrobe100,rtc,samsungyh*,sansac200*,sansae200*: ""
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
|
@ -3739,7 +3710,6 @@
|
|||
</dest>
|
||||
<voice>
|
||||
*: none
|
||||
gigabeat*,gogearsa9200,iaudiom5,iaudiox5,ipod*,iriverh10,iriverh100,iriverh10_5gb,iriverh120,iriverh300,mrobe100,rtc,samsungyh*,sansac200*,sansae200*: ""
|
||||
</voice>
|
||||
</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
|
||||
# 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!
|
||||
$(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)
|
||||
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
|
||||
perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(MODELNAME)$$feat $<
|
||||
$(SILENT)$(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(MODELNAME):`cat $(BUILDDIR)/apps/genlang-features` $<
|
||||
$(BUILDDIR)/lang/lang_core.c: $(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>
|
||||
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,
|
||||
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
|
||||
# state machine, so we don't bother to check.
|
||||
my $target_regex = "(?:^|,) *(?:\\*";
|
||||
my $model_regex = ""; # This matches the player model only!
|
||||
foreach my $target_part (split ':', $target) {
|
||||
for (my $c=1; $c<=length $target_part; $c++) {
|
||||
my $partial = substr $target_part, 0, $c;
|
||||
$target_regex .= "|$partial\\*";
|
||||
}
|
||||
$target_regex .= "|$target_part";
|
||||
$model_regex = $target_regex if (!$model_regex);
|
||||
}
|
||||
$target_regex .= ") *(?:,|\$)";
|
||||
$target_regex = qr/$target_regex/;
|
||||
$model_regex .= ") *(?:,|\$)";
|
||||
$model_regex = qr/$model_regex/;
|
||||
|
||||
my $binpath = "";
|
||||
if ($binary =~ m|(.*)/[^/]+|) {
|
||||
|
@ -170,7 +174,8 @@ sub parsetarget {
|
|||
my $string;
|
||||
if ($n =~ $target_regex) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -399,13 +399,12 @@ manual-7zip:
|
|||
|
||||
ifdef TTS_ENGINE
|
||||
|
||||
voice: voicetools $(BUILDDIR)/apps/features
|
||||
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
|
||||
if [ -z "$$POOL" ] ; then \
|
||||
voice: voicetools $(BUILDDIR)/apps/genlang-features
|
||||
$(SILENT)if [ -z "$$POOL" ] ; then \
|
||||
export POOL="$(BUILDDIR)/voice-pool" ; \
|
||||
fi;\
|
||||
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
|
||||
$(SILENT)if [ -z '$(TALKDIR)' ] ; then \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue