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
|
@ -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