From 799be1819031f8c3e35a65d2d7ced4f3d582c44f Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sat, 3 Dec 2022 00:18:09 +0100 Subject: [PATCH] locale: rework helpers Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/d69e1199032ced70a14d5eb78d99ce3bf385d0b5 Author: vanhofen Date: 2022-12-03 (Sat, 03 Dec 2022) Origin message was: ------------------ - locale: rework helpers ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/locale/Makefile.am | 47 +------------- data/locale/_readme.txt | 65 ------------------- data/locale/create-locale | 50 ++++++++++++++ data/locale/helpers/check-locale | 9 --- ...{create-locals-work => create-locale-work} | 63 ++++++++++-------- .../{create-locals.h => create-locals_h} | 8 ++- ...locals_intern.h => create-locals_intern_h} | 8 ++- 7 files changed, 97 insertions(+), 153 deletions(-) delete mode 100644 data/locale/_readme.txt create mode 100755 data/locale/create-locale delete mode 100755 data/locale/helpers/check-locale rename data/locale/helpers/{create-locals-work => create-locale-work} (51%) rename data/locale/helpers/{create-locals.h => create-locals_h} (90%) rename data/locale/helpers/{create-locals_intern.h => create-locals_intern_h} (89%) diff --git a/data/locale/Makefile.am b/data/locale/Makefile.am index 260ce211e..5de6e281e 100644 --- a/data/locale/Makefile.am +++ b/data/locale/Makefile.am @@ -8,49 +8,4 @@ unmaintained = \ nederlands.locale \ slovak.locale -# install_DATA += $(locale_unmaintained) - -if MAINTAINER_MODE - -master.locale=english.locale - -locals: sort-locals work-locals locals.h locals_intern.h - -$(master.locale) \ -sort-locals: - for locale in $(locale); do \ - cat $(top_srcdir)/data/locale/$${locale} | LC_ALL=C sort | uniq > $${locale}; \ - done - -work-locals: $(master.locale) - for locale in $(locale); do \ - ( cd $(top_srcdir)/data/locale; helpers/create-locals-work $${locale}; ); \ - done - -ordercheck: $(master.locale) - cut -d' ' -f1 $(top_srcdir)/data/locale/$(master.locale) | LC_ALL=C sort | uniq > /tmp/log - cut -d' ' -f1 $(top_srcdir)/data/locale/$(master.locale) | uniq | diff - /tmp/log || \ - (echo "ERROR: $(master.locale) not ordered or contains empty lines" && false) - -locals.h: ordercheck - cut -d' ' -f1 $(top_srcdir)/data/locale/$(master.locale) | LC_ALL=C sort | uniq | tr [:lower:] [:upper:] | tr \. \_ | tr \- \_ | tr -d \? | \ - $(top_srcdir)/data/locale/helpers/create-locals.h - -locals_intern.h: ordercheck - cut -d' ' -f1 $(top_srcdir)/data/locale/$(master.locale) | LC_ALL=C sort | uniq | \ - $(top_srcdir)/data/locale/helpers/create-locals_intern.h - -check: locals.h locals_intern.h - diff locals.h $(top_srcdir)/src/system - diff locals_intern.h $(top_srcdir)/src/system - -install-locals: $(locale) locals.h locals_intern.h - cp locals.h locals_intern.h $(top_srcdir)/src/system - @echo "Consider committing src/system/[locals.h locals_intern.h]" - ## ??? cp -f $(locale) $(top_srcdir)/data/locale - ## @echo "Consider committing data/locale/[$(locale)]" - -locals-clean: - rm -f locals.h locals_intern.h $(locale) - -endif +#install_DATA += $(unmaintained) diff --git a/data/locale/_readme.txt b/data/locale/_readme.txt deleted file mode 100644 index 0d417fdcb..000000000 --- a/data/locale/_readme.txt +++ /dev/null @@ -1,65 +0,0 @@ -Format of .locale files: ------------------------- -character encoding: UTF-8 -filename suffix : .locale - -Files must be strictly alphabetically ordered, and must not contain -any empty lines. - -Destination of .locale files: ------------------------------ -directory: /var/tuxbox/locale or /share/tuxbox/neutrino/locale - -Master file: ------------- -english.locale is considered the master file. - - -Verfication of .locale files: ------------------------------ -Use ./helpers/check-locale for detecting in master file -- violations of the sorting order, -- missing translations and -- legacy strings. - - - -How do I add a new locale string? ---------------------------------- -1.) -First of all, add the new string to english.locale while preserving -the ordering. Do not add any empty lines. - -2.) -Enter the directory build_tmp/neutrino-hd/data/locale. - -3.) -Use for sorting 'make sort-locals', use 'make ordercheck' to for verification. - -4.) -To the extent possible, update other locale file. For this, 'make work-locals' -may be useful. if you find a file called *.locale-work, merge this into *.locale - -5.) -Create new versions of the files src/system/locals.h and src/system/locals_intern.h -using the command 'make locals.h locals_intern.h'. - -6.) -Check the modifications with 'make check' - -7.) -Or use for item 3-6 'make locals' - -8.) -Copy the replacement file to their destination with 'make install-locals' - -9.) -If committing the changes to Git, commit both the involved -locale-files, src/system/locals.h, and src/system/locals_intern.h. - -Useful tools: -------------- -- emacs (add '(file-coding-system-alist (quote (("\\.locale\\'" . utf-8-unix) ("" undecided)))) to .emacs or use "C-x c utf-8 C-x C-f english.locale") -- iconv -- sort -- uxterm diff --git a/data/locale/create-locale b/data/locale/create-locale new file mode 100755 index 000000000..39c6223eb --- /dev/null +++ b/data/locale/create-locale @@ -0,0 +1,50 @@ +#!/bin/bash + +locale_master="deutsch.locale" +locale="${locale_master} english.locale" + +check_locale() { + cut -d' ' -f1 ${locale_master} | LC_ALL=C sort | uniq > /tmp/${locale_master} + for l in ${locale}; do + test $l == ${locale_master} && continue + echo $l: + echo "----------------" + cut -d' ' -f1 $l | diff -u - /tmp/${locale_master} + echo + done + rm /tmp/${locale_master} +} + +sort_locale() { + for l in ${locale}; do + cat ${l} | LC_ALL=C sort | uniq > ${l}.tmp + mv ${l}.tmp ${l} + done +} + +create_locale_work() { + for l in ${locale}; do + helpers/create-locale-work ${l} + done +} + +create_locals_h() { + cut -d' ' -f1 ${locale_master} | LC_ALL=C sort | uniq | tr [:lower:] [:upper:] | tr \. \_ | tr \- \_ | tr -d \? | \ + helpers/create-locals_h + mv locals.h ../../src/system +} + +create_locals_intern_h() { + cut -d' ' -f1 ${locale_master} | LC_ALL=C sort | uniq | \ + helpers/create-locals_intern_h + mv locals_intern.h ../../src/system +} + +#check_locale +sort_locale +create_locale_work +create_locals_h +create_locals_intern_h + +echo "Consider committing src/system/[locals.h locals_intern.h]" +echo "and data/locale/[${locale}]" diff --git a/data/locale/helpers/check-locale b/data/locale/helpers/check-locale deleted file mode 100755 index 5b3cf27d1..000000000 --- a/data/locale/helpers/check-locale +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -cut -d' ' -f1 english.locale | sort | uniq > /tmp/log -for i in *.locale; do \ - echo $i:; \ - echo "----------------"; \ - cut -d' ' -f1 $i | diff -u - /tmp/log; \ - echo; \ -done -rm /tmp/log diff --git a/data/locale/helpers/create-locals-work b/data/locale/helpers/create-locale-work similarity index 51% rename from data/locale/helpers/create-locals-work rename to data/locale/helpers/create-locale-work index f9a54ee55..0d24aa304 100755 --- a/data/locale/helpers/create-locals-work +++ b/data/locale/helpers/create-locale-work @@ -9,14 +9,14 @@ # reorganized by Stefan Seyfried 2016-01-03, following changes: # * use strict, use warnings to find errors easier # * make it work with the above pragmas -# * tolerance against empty locales in english.locale +# * tolerance against empty locales in deutsch.locale use warnings; use strict; -my $masterfilename = "english.locale"; +my $masterfilename = "deutsch.locale"; -$#ARGV == 0 || die("Usage: create-locals-work file.locale."); +$#ARGV == 0 || die("Usage: create-locals-work file.locale"); my $no_errors = 0; my $last_was_ok = 1; @@ -31,36 +31,45 @@ my %master; my %locale; my $line; -while ($line = ) { - # master hash - chomp $line; - $line =~ s/^\s+//; # strip whitespace from start of line - my ($key, $text) = split /\s+/, $line, 2; - $master{$key} = $text ? $text : ""; +while ($line = ) +{ + # master hash + chomp $line; + $line =~ s/^\s+//; # strip whitespace from start of line + my ($key, $text) = split /\s+/, $line, 2; + $master{$key} = $text ? $text : ""; } close(MASTER); -while ($line = ) { - # locale hash - chomp $line; - $line =~ s/^\s+//; - my ($key, $text) = split /\s+/, $line, 2; - $locale{$key} = $text ? $text : ""; +while ($line = ) +{ + # locale hash + chomp $line; + $line =~ s/^\s+//; + my ($key, $text) = split /\s+/, $line, 2; + $locale{$key} = $text ? $text : ""; } close(LOCALE); -foreach my $term (sort keys %master) { - if (exists $locale{$term}) { - print OUT $term." ".$locale{$term}."\n"; - } else { - # not found - $no_errors++; - print OUT $term." TRANSLATE ".$master{$term}."\n"; - } +foreach my $term (sort keys %master) +{ + if (exists $locale{$term}) + { + print OUT $term." ".$locale{$term}."\n"; + } + else + { + # not found + $no_errors++; + print OUT $term." (((T))) ".$master{$term}."\n"; + } } -if ($no_errors == 0) { - unlink($outfilename); -} else { - print "There were ", $no_errors, " error(s) in ", $localefilename, ".\n"; +if ($no_errors == 0) +{ + unlink($outfilename); +} +else +{ + print "There were ", $no_errors, " error(s) in ", $localefilename, ".\n"; } diff --git a/data/locale/helpers/create-locals.h b/data/locale/helpers/create-locals_h similarity index 90% rename from data/locale/helpers/create-locals.h rename to data/locale/helpers/create-locals_h index 6752aac6c..db189121d 100755 --- a/data/locale/helpers/create-locals.h +++ b/data/locale/helpers/create-locals_h @@ -1,6 +1,7 @@ #!/bin/bash -# usage: cut -d' ' -f1 english.locale | LC_ALL=C sort | uniq | tr [:lower:] [:upper:] | tr \. \_ | tr \- \_ | tr -d \? | ./helpers/create-locals.h -cat > locals.h < locals.h << EOH #ifndef __locals__ #define __locals__ @@ -28,13 +29,14 @@ cat > locals.h <> locals.h while read id; do printf ",\n\tLOCALE_$id" >> locals.h; done -cat >> locals.h <> locals.h << EOF } neutrino_locale_t; #endif diff --git a/data/locale/helpers/create-locals_intern.h b/data/locale/helpers/create-locals_intern_h similarity index 89% rename from data/locale/helpers/create-locals_intern.h rename to data/locale/helpers/create-locals_intern_h index 243097c53..1f0f9d191 100755 --- a/data/locale/helpers/create-locals_intern.h +++ b/data/locale/helpers/create-locals_intern_h @@ -1,6 +1,7 @@ #!/bin/bash -# usage: cut -d' ' -f1 english.locale | LC_ALL=C sort | uniq | ./helpers/create-locals_intern.h -cat > locals_intern.h < locals_intern.h << EOH #ifndef __locals_intern__ #define __locals_intern__ @@ -28,13 +29,14 @@ cat > locals_intern.h <> locals_intern.h while read id; do printf ",\n\t\"$id\"" >> locals_intern.h done -cat >> locals_intern.h <> locals_intern.h << EOF }; #endif