-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add japanese translation; translation tools
- Loading branch information
Showing
3 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Japanese translations for Time-Ago package. | ||
# Copyright (C) 2015 Maurice Aubrey | ||
# This file is distributed under the same license as the Time-Ago package. | ||
# Automatically generated, 2015. | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Time-Ago 0.06\n" | ||
"Report-Msgid-Bugs-To: [email protected]\n" | ||
"POT-Creation-Date: 2015-07-18 13:41-0700\n" | ||
"PO-Revision-Date: 2015-07-18 13:41-0700\n" | ||
"Last-Translator: Automatically generated\n" | ||
"Language-Team: none\n" | ||
"Language: ja\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=ASCII\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=1; plural=0;\n" | ||
|
||
#: lib/Time/Ago.pm:47 | ||
#, perl-brace-format | ||
msgid "about {count} hour" | ||
msgid_plural "about {count} hours" | ||
msgstr[0] "" | ||
|
||
#: lib/Time/Ago.pm:51 | ||
#, perl-brace-format | ||
msgid "about {count} month" | ||
msgid_plural "about {count} months" | ||
msgstr[0] "" | ||
|
||
#: lib/Time/Ago.pm:55 | ||
#, perl-brace-format | ||
msgid "about {count} year" | ||
msgid_plural "about {count} years" | ||
msgstr[0] "" | ||
|
||
#: lib/Time/Ago.pm:59 | ||
#, perl-brace-format | ||
msgid "almost {count} year" | ||
msgid_plural "almost {count} years" | ||
msgstr[0] "" | ||
|
||
#: lib/Time/Ago.pm:62 | ||
msgid "half a minute" | ||
msgstr "" | ||
|
||
#: lib/Time/Ago.pm:65 | ||
#, perl-brace-format | ||
msgid "less than a minute" | ||
msgid_plural "less than {count} minutes" | ||
msgstr[0] "" | ||
|
||
#: lib/Time/Ago.pm:70 | ||
#, perl-brace-format | ||
msgid "less than {count} second" | ||
msgid_plural "less than {count} seconds" | ||
msgstr[0] "" | ||
|
||
#: lib/Time/Ago.pm:78 | ||
#, perl-brace-format | ||
msgid "over {count} year" | ||
msgid_plural "over {count} years" | ||
msgstr[0] "" | ||
|
||
#: lib/Time/Ago.pm:82 | ||
#, perl-brace-format | ||
msgid "{count} day" | ||
msgid_plural "{count} days" | ||
msgstr[0] "" | ||
|
||
#: lib/Time/Ago.pm:86 | ||
#, perl-brace-format | ||
msgid "{count} minute" | ||
msgid_plural "{count} minutes" | ||
msgstr[0] "" | ||
|
||
#: lib/Time/Ago.pm:90 | ||
#, perl-brace-format | ||
msgid "{count} month" | ||
msgid_plural "{count} months" | ||
msgstr[0] "" | ||
|
||
msgid "{count} second" | ||
msgid_plural "{count} seconds" | ||
msgstr[0] "" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/usr/bin/env perl | ||
|
||
# Usage: ruby-i18n-to-gettext <ruby-translation.yml> <gettext-po> | ||
# | ||
# Converts a ruby translation file for time_ago_in_words to the | ||
# equivalent gettext .po version. | ||
# | ||
# There's a bunch of mappings below that are specific to the | ||
# time_ago_in_words project. | ||
|
||
use strict; | ||
use warnings; | ||
use autodie qw/ :all /; | ||
use open qw/ :std :utf8 /; | ||
use File::Basename qw/ fileparse /; | ||
use YAML::XS qw/ LoadFile /; | ||
|
||
# map between gettext msgid and ruby msgid | ||
my %map = ( | ||
'about {count} hour' => 'about_x_hours', | ||
'about {count} month' => 'about_x_months', | ||
'about {count} year' => 'about_x_years', | ||
'almost {count} year' => 'almost_x_years', | ||
'half a minute' => 'half_a_minute', | ||
'less than a minute' => 'less_than_x_minutes', | ||
'less than {count} second' => 'less_than_x_seconds', | ||
'over {count} year' => 'over_x_years', | ||
'{count} day' => 'x_days', | ||
'{count} minute' => 'x_minutes', | ||
'{count} month' => 'x_months', | ||
'{count} second' => 'x_seconds', | ||
); | ||
|
||
# How the gettext msgstr[IDX] values map to the ruby i18n plural forms | ||
my %forms = ( | ||
default => { | ||
0 => 'one', | ||
1 => 'other', | ||
}, | ||
|
||
ja => { | ||
0 => 'other', | ||
}, | ||
|
||
ru => { | ||
0 => 'one', | ||
1 => 'few', | ||
2 => 'many', | ||
}, | ||
); | ||
|
||
|
||
@ARGV == 2 or die "Usage: $0 <ruby-translation.yml> <gettext-po>\n"; | ||
|
||
my $yaml_file = shift @ARGV; | ||
my $po_file = shift @ARGV; | ||
|
||
my $yaml = LoadFile($yaml_file); | ||
|
||
my $lang = fileparse($yaml_file, '.yml', '.yaml') | ||
or die "unable to determine language from file '$yaml_file'"; | ||
|
||
$yaml = $yaml->{ $lang }{datetime}{distance_in_words} | ||
or die "didn't find distance_in_words hash"; | ||
|
||
my $forms = $forms{ $lang } || $forms{default} or die 'no plural forms?!'; | ||
|
||
open my $fh, '<', $po_file; | ||
my ($msgid, $ruby_msgid); | ||
while (<$fh>) { | ||
if ($msgid) { | ||
if (/^\s* msgstr(?:\[(\d+)])? \s+ ""/x) { | ||
my $phrases = $yaml->{ $ruby_msgid } | ||
or die "translation for ruby msgid '$ruby_msgid' not found"; | ||
|
||
my $idx = $1; | ||
|
||
if (defined $idx) { # multiple plural forms | ||
my $phrase_form = $forms->{ $idx } | ||
or die "unexpected plural index '$idx'"; | ||
|
||
my $phrase = $phrases->{ $phrase_form } | ||
or die "translation for ruby msgid '$ruby_msgid' form " . | ||
"'$phrase_form' not found"; | ||
|
||
$_ = qq{msgstr[$idx] "$phrase"\n}; | ||
} else { # single phrase | ||
!ref $phrases | ||
or die "translation of '$ruby_msgid' has multiple forms"; | ||
$_ = qq{msgstr "$phrases"\n}; | ||
} | ||
|
||
# convert ruby placeholders to gettext placeholders | ||
s/%{([^}]+)}/{$1}/g; | ||
} | ||
} | ||
|
||
# Start of new translation block | ||
if (/^\s* msgid \s+ "(.+)"/x) { | ||
$msgid = $1; | ||
|
||
$ruby_msgid = delete $map{ $msgid } | ||
or die "unknown ruby mapping from msgid '$msgid'"; | ||
} | ||
} continue { | ||
print; | ||
} | ||
|
||
if (keys %map) { | ||
my $keys = join ', ', sort keys %map; | ||
die "No mapping found for the following msgids: $keys\n"; | ||
} | ||
|
||
exit 0; |