mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 15:02:50 +02:00
locale: rework helpers
Origin commit data
------------------
Branch: ni/coolstream
Commit: d69e119903
Author: vanhofen <vanhofen@gmx.de>
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
This commit is contained in:
@@ -8,49 +8,4 @@ unmaintained = \
|
|||||||
nederlands.locale \
|
nederlands.locale \
|
||||||
slovak.locale
|
slovak.locale
|
||||||
|
|
||||||
# install_DATA += $(locale_unmaintained)
|
#install_DATA += $(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
|
|
||||||
|
@@ -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 <RET> c utf-8 <RET> C-x C-f english.locale")
|
|
||||||
- iconv
|
|
||||||
- sort
|
|
||||||
- uxterm
|
|
50
data/locale/create-locale
Executable file
50
data/locale/create-locale
Executable file
@@ -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}]"
|
@@ -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
|
|
@@ -9,14 +9,14 @@
|
|||||||
# reorganized by Stefan Seyfried 2016-01-03, following changes:
|
# reorganized by Stefan Seyfried 2016-01-03, following changes:
|
||||||
# * use strict, use warnings to find errors easier
|
# * use strict, use warnings to find errors easier
|
||||||
# * make it work with the above pragmas
|
# * make it work with the above pragmas
|
||||||
# * tolerance against empty locales in english.locale
|
# * tolerance against empty locales in deutsch.locale
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
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 $no_errors = 0;
|
||||||
my $last_was_ok = 1;
|
my $last_was_ok = 1;
|
||||||
@@ -31,36 +31,45 @@ my %master;
|
|||||||
my %locale;
|
my %locale;
|
||||||
|
|
||||||
my $line;
|
my $line;
|
||||||
while ($line = <MASTER>) {
|
while ($line = <MASTER>)
|
||||||
# master hash
|
{
|
||||||
chomp $line;
|
# master hash
|
||||||
$line =~ s/^\s+//; # strip whitespace from start of line
|
chomp $line;
|
||||||
my ($key, $text) = split /\s+/, $line, 2;
|
$line =~ s/^\s+//; # strip whitespace from start of line
|
||||||
$master{$key} = $text ? $text : "";
|
my ($key, $text) = split /\s+/, $line, 2;
|
||||||
|
$master{$key} = $text ? $text : "";
|
||||||
}
|
}
|
||||||
close(MASTER);
|
close(MASTER);
|
||||||
|
|
||||||
while ($line = <LOCALE>) {
|
while ($line = <LOCALE>)
|
||||||
# locale hash
|
{
|
||||||
chomp $line;
|
# locale hash
|
||||||
$line =~ s/^\s+//;
|
chomp $line;
|
||||||
my ($key, $text) = split /\s+/, $line, 2;
|
$line =~ s/^\s+//;
|
||||||
$locale{$key} = $text ? $text : "";
|
my ($key, $text) = split /\s+/, $line, 2;
|
||||||
|
$locale{$key} = $text ? $text : "";
|
||||||
}
|
}
|
||||||
close(LOCALE);
|
close(LOCALE);
|
||||||
|
|
||||||
foreach my $term (sort keys %master) {
|
foreach my $term (sort keys %master)
|
||||||
if (exists $locale{$term}) {
|
{
|
||||||
print OUT $term." ".$locale{$term}."\n";
|
if (exists $locale{$term})
|
||||||
} else {
|
{
|
||||||
# not found
|
print OUT $term." ".$locale{$term}."\n";
|
||||||
$no_errors++;
|
}
|
||||||
print OUT $term." TRANSLATE ".$master{$term}."\n";
|
else
|
||||||
}
|
{
|
||||||
|
# not found
|
||||||
|
$no_errors++;
|
||||||
|
print OUT $term." (((T))) ".$master{$term}."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($no_errors == 0) {
|
if ($no_errors == 0)
|
||||||
unlink($outfilename);
|
{
|
||||||
} else {
|
unlink($outfilename);
|
||||||
print "There were ", $no_errors, " error(s) in ", $localefilename, ".\n";
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "There were ", $no_errors, " error(s) in ", $localefilename, ".\n";
|
||||||
}
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# usage: cut -d' ' -f1 english.locale | LC_ALL=C sort | uniq | tr [:lower:] [:upper:] | tr \. \_ | tr \- \_ | tr -d \? | ./helpers/create-locals.h
|
# usage: cut -d' ' -f1 deutsch.locale | LC_ALL=C sort | uniq | tr [:lower:] [:upper:] | tr \. \_ | tr \- \_ | tr -d \? | ./helpers/create-locals.h
|
||||||
cat > locals.h <<EOH
|
|
||||||
|
cat > locals.h << EOH
|
||||||
#ifndef __locals__
|
#ifndef __locals__
|
||||||
#define __locals__
|
#define __locals__
|
||||||
|
|
||||||
@@ -28,13 +29,14 @@ cat > locals.h <<EOH
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
EOH
|
EOH
|
||||||
|
|
||||||
printf "\tNONEXISTANT_LOCALE" >> locals.h
|
printf "\tNONEXISTANT_LOCALE" >> locals.h
|
||||||
|
|
||||||
while read id; do
|
while read id; do
|
||||||
printf ",\n\tLOCALE_$id" >> locals.h;
|
printf ",\n\tLOCALE_$id" >> locals.h;
|
||||||
done
|
done
|
||||||
|
|
||||||
cat >> locals.h <<EOF
|
cat >> locals.h << EOF
|
||||||
|
|
||||||
} neutrino_locale_t;
|
} neutrino_locale_t;
|
||||||
#endif
|
#endif
|
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# usage: cut -d' ' -f1 english.locale | LC_ALL=C sort | uniq | ./helpers/create-locals_intern.h
|
# usage: cut -d' ' -f1 deutsch.locale | LC_ALL=C sort | uniq | ./helpers/create-locals_intern.h
|
||||||
cat > locals_intern.h <<EOH
|
|
||||||
|
cat > locals_intern.h << EOH
|
||||||
#ifndef __locals_intern__
|
#ifndef __locals_intern__
|
||||||
#define __locals_intern__
|
#define __locals_intern__
|
||||||
|
|
||||||
@@ -28,13 +29,14 @@ cat > locals_intern.h <<EOH
|
|||||||
const char * locale_real_names[] =
|
const char * locale_real_names[] =
|
||||||
{
|
{
|
||||||
EOH
|
EOH
|
||||||
|
|
||||||
printf "\t\"INTERNAL ERROR - PLEASE REPORT\"" >> locals_intern.h
|
printf "\t\"INTERNAL ERROR - PLEASE REPORT\"" >> locals_intern.h
|
||||||
|
|
||||||
while read id; do
|
while read id; do
|
||||||
printf ",\n\t\"$id\"" >> locals_intern.h
|
printf ",\n\t\"$id\"" >> locals_intern.h
|
||||||
done
|
done
|
||||||
|
|
||||||
cat >> locals_intern.h <<EOF
|
cat >> locals_intern.h << EOF
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user