Table::Trans - simple translations for templating
use Table::Trans;
This documents version 0.00_01 of Table-Trans corresponding to git commit bcdc6d76d92a1a70412803559f8e2dd72419537f released on Fri Jan 29 08:47:28 2021 +0900.
Very simple translation storage based on the Table::Readable format. We made this because TMX (Translation Memory eXchange, an XML format) was such a pain to use.
my $language = get_lang_name ($lang);
Given a language code like en, convert it into the native name of the language, like "English".
en
get_lang_trans ($trans, $vars, $lang);
Put the translations from $trans for language $lang into $vars->{trans}.
my $trans = read_trans ('file.txt');
Also get the order:
my ($trans, $order) = read_trans ('file.txt');
Read a file of translations in Table::Readable format.
trans_to_json_file ('file.txt', 'file.json');
Convert the translations in file.txt into file.json.
write_trans (\%trans, [qw/en ja es/], "output.txt", \@id_order);
Write the translations stored in %trans for the languages "en", "ja" and "es" in the order given by @id_order to the file output.txt in the Table::Readable format.
%trans
@id_order
output.txt
The basic format of the translations is the Table::Readable format, with each translated piece of text being identified with the code id then each particular language having its own entry.
id
Unfortunately the language code for Indonesian is id, so this module may have to be updated to cope with the Indonesian language.
Macros to insert another translation can be used in the form {{id}} and the translation of id in the language of the entry will be inserted, so if we have
{{id}}
id: ape en: monkey ja: さる id: monkeyshines en: {{ape}}shines ja: {{ape}}さわぎ
then the ja entry for the ID "monkeyshines" will be さるさわぎ and the English entry will be "monkeyshines". There is currently no cross-language way of getting macros or non-language way of inserting them.
ja
This is used for storing the translations in JSON format.
This is only used by the tests.
This is used as the basic format for storing and editing translations.
Ben Bullock, <bkb@cpan.org>
This package and associated files are copyright (C) 2021 Ben Bullock.
You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.
To install Table::Trans, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Table::Trans
CPAN shell
perl -MCPAN -e shell install Table::Trans
For more information on module installation, please visit the detailed CPAN module installation guide.