sayso-i18n 0.5.0.001
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.textile +152 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +103 -0
- data/ci/Gemfile.no-rails +5 -0
- data/ci/Gemfile.no-rails.lock +14 -0
- data/ci/Gemfile.rails-2.3.x +9 -0
- data/ci/Gemfile.rails-2.3.x.lock +23 -0
- data/ci/Gemfile.rails-3.x +9 -0
- data/ci/Gemfile.rails-3.x.lock +23 -0
- data/lib/i18n.rb +324 -0
- data/lib/i18n/backend.rb +19 -0
- data/lib/i18n/backend/base.rb +174 -0
- data/lib/i18n/backend/cache.rb +102 -0
- data/lib/i18n/backend/cascade.rb +53 -0
- data/lib/i18n/backend/chain.rb +80 -0
- data/lib/i18n/backend/fallbacks.rb +70 -0
- data/lib/i18n/backend/flatten.rb +113 -0
- data/lib/i18n/backend/flatten_yml.rb +70 -0
- data/lib/i18n/backend/gettext.rb +71 -0
- data/lib/i18n/backend/interpolation_compiler.rb +121 -0
- data/lib/i18n/backend/key_value.rb +100 -0
- data/lib/i18n/backend/memoize.rb +46 -0
- data/lib/i18n/backend/metadata.rb +65 -0
- data/lib/i18n/backend/pluralization.rb +55 -0
- data/lib/i18n/backend/simple.rb +87 -0
- data/lib/i18n/backend/transliterator.rb +98 -0
- data/lib/i18n/config.rb +86 -0
- data/lib/i18n/core_ext/hash.rb +29 -0
- data/lib/i18n/core_ext/kernel/surpress_warnings.rb +9 -0
- data/lib/i18n/core_ext/string/interpolate.rb +105 -0
- data/lib/i18n/exceptions.rb +88 -0
- data/lib/i18n/gettext.rb +25 -0
- data/lib/i18n/gettext/helpers.rb +64 -0
- data/lib/i18n/gettext/po_parser.rb +329 -0
- data/lib/i18n/interpolate/ruby.rb +31 -0
- data/lib/i18n/locale.rb +6 -0
- data/lib/i18n/locale/fallbacks.rb +96 -0
- data/lib/i18n/locale/tag.rb +28 -0
- data/lib/i18n/locale/tag/parents.rb +22 -0
- data/lib/i18n/locale/tag/rfc4646.rb +74 -0
- data/lib/i18n/locale/tag/simple.rb +39 -0
- data/lib/i18n/tests.rb +12 -0
- data/lib/i18n/tests/basics.rb +54 -0
- data/lib/i18n/tests/defaults.rb +40 -0
- data/lib/i18n/tests/interpolation.rb +133 -0
- data/lib/i18n/tests/link.rb +56 -0
- data/lib/i18n/tests/localization.rb +19 -0
- data/lib/i18n/tests/localization/date.rb +84 -0
- data/lib/i18n/tests/localization/date_time.rb +77 -0
- data/lib/i18n/tests/localization/procs.rb +116 -0
- data/lib/i18n/tests/localization/time.rb +76 -0
- data/lib/i18n/tests/lookup.rb +74 -0
- data/lib/i18n/tests/pluralization.rb +35 -0
- data/lib/i18n/tests/procs.rb +55 -0
- data/lib/i18n/version.rb +3 -0
- data/test/all.rb +8 -0
- data/test/api/all_features_test.rb +58 -0
- data/test/api/cascade_test.rb +28 -0
- data/test/api/chain_test.rb +24 -0
- data/test/api/fallbacks_test.rb +30 -0
- data/test/api/flatten_yml_test.rb +32 -0
- data/test/api/key_value_test.rb +28 -0
- data/test/api/memoize_test.rb +60 -0
- data/test/api/pluralization_test.rb +30 -0
- data/test/api/simple_test.rb +28 -0
- data/test/backend/cache_test.rb +83 -0
- data/test/backend/cascade_test.rb +85 -0
- data/test/backend/chain_test.rb +72 -0
- data/test/backend/exceptions_test.rb +23 -0
- data/test/backend/fallbacks_test.rb +120 -0
- data/test/backend/flatten_yml_test.rb +49 -0
- data/test/backend/interpolation_compiler_test.rb +102 -0
- data/test/backend/key_value_test.rb +46 -0
- data/test/backend/memoize_test.rb +47 -0
- data/test/backend/metadata_test.rb +67 -0
- data/test/backend/pluralization_test.rb +44 -0
- data/test/backend/simple_test.rb +83 -0
- data/test/backend/transliterator_test.rb +81 -0
- data/test/core_ext/hash_test.rb +30 -0
- data/test/core_ext/string/interpolate_test.rb +99 -0
- data/test/gettext/api_test.rb +206 -0
- data/test/gettext/backend_test.rb +93 -0
- data/test/i18n/exceptions_test.rb +116 -0
- data/test/i18n/interpolate_test.rb +61 -0
- data/test/i18n/load_path_test.rb +26 -0
- data/test/i18n_test.rb +236 -0
- data/test/locale/fallbacks_test.rb +124 -0
- data/test/locale/tag/rfc4646_test.rb +142 -0
- data/test/locale/tag/simple_test.rb +32 -0
- data/test/run_all.rb +21 -0
- data/test/test_data/locales/de.po +72 -0
- data/test/test_data/locales/en.rb +3 -0
- data/test/test_data/locales/en.yml +3 -0
- data/test/test_data/locales/invalid/empty.yml +1 -0
- data/test/test_data/locales/plurals.rb +113 -0
- data/test/test_helper.rb +56 -0
- metadata +194 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
# This backports the Ruby 1.9 String interpolation syntax to Ruby 1.8.
|
2
|
+
#
|
3
|
+
# This backport has been shipped with I18n for a number of versions. Meanwhile
|
4
|
+
# Rails has started to rely on it and we are going to move it to ActiveSupport.
|
5
|
+
# See https://rails.lighthouseapp.com/projects/8994/tickets/6013-move-19-string-interpolation-syntax-backport-from-i18n-to-activesupport
|
6
|
+
#
|
7
|
+
# Once the above patch has been applied to Rails the following code will be
|
8
|
+
# removed from I18n.
|
9
|
+
|
10
|
+
=begin
|
11
|
+
heavily based on Masao Mutoh's gettext String interpolation extension
|
12
|
+
http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb
|
13
|
+
Copyright (C) 2005-2009 Masao Mutoh
|
14
|
+
You may redistribute it and/or modify it under the same license terms as Ruby.
|
15
|
+
=end
|
16
|
+
|
17
|
+
begin
|
18
|
+
raise ArgumentError if ("a %{x}" % {:x=>'b'}) != 'a b'
|
19
|
+
rescue ArgumentError
|
20
|
+
# KeyError is raised by String#% when the string contains a named placeholder
|
21
|
+
# that is not contained in the given arguments hash. Ruby 1.9 includes and
|
22
|
+
# raises this exception natively. We define it to mimic Ruby 1.9's behaviour
|
23
|
+
# in Ruby 1.8.x
|
24
|
+
class KeyError < IndexError
|
25
|
+
def initialize(message = nil)
|
26
|
+
super(message || "key not found")
|
27
|
+
end
|
28
|
+
end unless defined?(KeyError)
|
29
|
+
|
30
|
+
# Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError.
|
31
|
+
#
|
32
|
+
# String#% method which accept "named argument". The translator can know
|
33
|
+
# the meaning of the msgids using "named argument" instead of %s/%d style.
|
34
|
+
class String
|
35
|
+
# For older ruby versions, such as ruby-1.8.5
|
36
|
+
alias :bytesize :size unless instance_methods.find {|m| m.to_s == 'bytesize'}
|
37
|
+
alias :interpolate_without_ruby_19_syntax :% # :nodoc:
|
38
|
+
|
39
|
+
INTERPOLATION_PATTERN = Regexp.union(
|
40
|
+
/%\{(\w+)\}/, # matches placeholders like "%{foo}"
|
41
|
+
/%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%<foo>.d"
|
42
|
+
)
|
43
|
+
|
44
|
+
INTERPOLATION_PATTERN_WITH_ESCAPE = Regexp.union(
|
45
|
+
/%%/,
|
46
|
+
INTERPOLATION_PATTERN
|
47
|
+
)
|
48
|
+
|
49
|
+
# % uses self (i.e. the String) as a format specification and returns the
|
50
|
+
# result of applying it to the given arguments. In other words it interpolates
|
51
|
+
# the given arguments to the string according to the formats the string
|
52
|
+
# defines.
|
53
|
+
#
|
54
|
+
# There are three ways to use it:
|
55
|
+
#
|
56
|
+
# * Using a single argument or Array of arguments.
|
57
|
+
#
|
58
|
+
# This is the default behaviour of the String class. See Kernel#sprintf for
|
59
|
+
# more details about the format string.
|
60
|
+
#
|
61
|
+
# Example:
|
62
|
+
#
|
63
|
+
# "%d %s" % [1, "message"]
|
64
|
+
# # => "1 message"
|
65
|
+
#
|
66
|
+
# * Using a Hash as an argument and unformatted, named placeholders.
|
67
|
+
#
|
68
|
+
# When you pass a Hash as an argument and specify placeholders with %{foo}
|
69
|
+
# it will interpret the hash values as named arguments.
|
70
|
+
#
|
71
|
+
# Example:
|
72
|
+
#
|
73
|
+
# "%{firstname}, %{lastname}" % {:firstname => "Masao", :lastname => "Mutoh"}
|
74
|
+
# # => "Masao Mutoh"
|
75
|
+
#
|
76
|
+
# * Using a Hash as an argument and formatted, named placeholders.
|
77
|
+
#
|
78
|
+
# When you pass a Hash as an argument and specify placeholders with %<foo>d
|
79
|
+
# it will interpret the hash values as named arguments and format the value
|
80
|
+
# according to the formatting instruction appended to the closing >.
|
81
|
+
#
|
82
|
+
# Example:
|
83
|
+
#
|
84
|
+
# "%<integer>d, %<float>.1f" % { :integer => 10, :float => 43.4 }
|
85
|
+
# # => "10, 43.3"
|
86
|
+
def %(args)
|
87
|
+
if args.kind_of?(Hash)
|
88
|
+
dup.gsub(INTERPOLATION_PATTERN_WITH_ESCAPE) do |match|
|
89
|
+
if match == '%%'
|
90
|
+
'%'
|
91
|
+
else
|
92
|
+
key = ($1 || $2).to_sym
|
93
|
+
raise KeyError unless args.has_key?(key)
|
94
|
+
$3 ? sprintf("%#{$3}", args[key]) : args[key]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
elsif self =~ INTERPOLATION_PATTERN
|
98
|
+
raise ArgumentError.new('one hash required')
|
99
|
+
else
|
100
|
+
result = gsub(/%([{<])/, '%%\1')
|
101
|
+
result.send :'interpolate_without_ruby_19_syntax', args
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module I18n
|
2
|
+
# Handles exceptions raised in the backend. All exceptions except for
|
3
|
+
# MissingTranslationData exceptions are re-raised. When a MissingTranslationData
|
4
|
+
# was caught the handler returns an error message string containing the key/scope.
|
5
|
+
# Note that the exception handler is not called when the option :raise was given.
|
6
|
+
class ExceptionHandler
|
7
|
+
include Module.new {
|
8
|
+
def call(exception, locale, key, options)
|
9
|
+
if exception.is_a?(MissingTranslationData)
|
10
|
+
options[:rescue_format] == :html ? exception.html_message : exception.message
|
11
|
+
else
|
12
|
+
raise exception
|
13
|
+
end
|
14
|
+
end
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
class ArgumentError < ::ArgumentError; end
|
19
|
+
|
20
|
+
class InvalidLocale < ArgumentError
|
21
|
+
attr_reader :locale
|
22
|
+
def initialize(locale)
|
23
|
+
@locale = locale
|
24
|
+
super "#{locale.inspect} is not a valid locale"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class InvalidLocaleData < ArgumentError
|
29
|
+
attr_reader :filename
|
30
|
+
def initialize(filename)
|
31
|
+
@filename = filename
|
32
|
+
super "can not load translations from #{filename}, expected it to return a hash, but does not"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class MissingTranslationData < ArgumentError
|
37
|
+
attr_reader :locale, :key, :options
|
38
|
+
|
39
|
+
def initialize(locale, key, opts = nil)
|
40
|
+
@key, @locale, @options = key, locale, opts.dup || {}
|
41
|
+
options.each { |k, v| options[k] = v.inspect if v.is_a?(Proc) }
|
42
|
+
super "translation missing: #{keys.join('.')}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def html_message
|
46
|
+
key = keys.last.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize }
|
47
|
+
%(<span class="translation_missing" title="translation missing: #{keys.join('.')}">#{key}</span>)
|
48
|
+
end
|
49
|
+
|
50
|
+
def keys
|
51
|
+
@keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys|
|
52
|
+
keys << 'no key' if keys.size < 2
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class InvalidPluralizationData < ArgumentError
|
58
|
+
attr_reader :entry, :count
|
59
|
+
def initialize(entry, count)
|
60
|
+
@entry, @count = entry, count
|
61
|
+
super "translation data #{entry.inspect} can not be used with :count => #{count}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class MissingInterpolationArgument < ArgumentError
|
66
|
+
attr_reader :values, :string
|
67
|
+
def initialize(values, string)
|
68
|
+
@values, @string = values, string
|
69
|
+
super "missing interpolation argument in #{string.inspect} (#{values.inspect} given)"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class ReservedInterpolationKey < ArgumentError
|
74
|
+
attr_reader :key, :string
|
75
|
+
def initialize(key, string)
|
76
|
+
@key, @string = key, string
|
77
|
+
super "reserved key #{key.inspect} used in #{string.inspect}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class UnknownFileType < ArgumentError
|
82
|
+
attr_reader :type, :filename
|
83
|
+
def initialize(type, filename)
|
84
|
+
@type, @filename = type, filename
|
85
|
+
super "can not load translations from #{filename}, the file type #{type} is not known"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/i18n/gettext.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module I18n
|
2
|
+
module Gettext
|
3
|
+
PLURAL_SEPARATOR = "\001"
|
4
|
+
CONTEXT_SEPARATOR = "\004"
|
5
|
+
|
6
|
+
autoload :Helpers, 'i18n/gettext/helpers'
|
7
|
+
|
8
|
+
@@plural_keys = { :en => [:one, :other] }
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# returns an array of plural keys for the given locale so that we can
|
12
|
+
# convert from gettext's integer-index based style
|
13
|
+
# TODO move this information to the pluralization module
|
14
|
+
def plural_keys(locale)
|
15
|
+
@@plural_keys[locale] || @@plural_keys[:en]
|
16
|
+
end
|
17
|
+
|
18
|
+
def extract_scope(msgid, separator)
|
19
|
+
scope = msgid.to_s.split(separator)
|
20
|
+
msgid = scope.pop
|
21
|
+
[scope, msgid]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'i18n/gettext'
|
2
|
+
|
3
|
+
module I18n
|
4
|
+
module Gettext
|
5
|
+
# Implements classical Gettext style accessors. To use this include the
|
6
|
+
# module to the global namespace or wherever you want to use it.
|
7
|
+
#
|
8
|
+
# include I18n::Gettext::Helpers
|
9
|
+
module Helpers
|
10
|
+
def gettext(msgid, options = {})
|
11
|
+
I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options))
|
12
|
+
end
|
13
|
+
alias _ gettext
|
14
|
+
|
15
|
+
def sgettext(msgid, separator = '|')
|
16
|
+
scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
|
17
|
+
I18n.t(msgid, :scope => scope, :default => msgid, :separator => separator)
|
18
|
+
end
|
19
|
+
alias s_ sgettext
|
20
|
+
|
21
|
+
def pgettext(msgctxt, msgid)
|
22
|
+
separator = I18n::Gettext::CONTEXT_SEPARATOR
|
23
|
+
sgettext([msgctxt, msgid].join(separator), separator)
|
24
|
+
end
|
25
|
+
alias p_ pgettext
|
26
|
+
|
27
|
+
def ngettext(msgid, msgid_plural, n = 1)
|
28
|
+
nsgettext(msgid, msgid_plural, n)
|
29
|
+
end
|
30
|
+
alias n_ ngettext
|
31
|
+
|
32
|
+
# Method signatures:
|
33
|
+
# nsgettext('Fruits|apple', 'apples', 2)
|
34
|
+
# nsgettext(['Fruits|apple', 'apples'], 2)
|
35
|
+
def nsgettext(msgid, msgid_plural, n = 1, separator = '|')
|
36
|
+
if msgid.is_a?(Array)
|
37
|
+
msgid, msgid_plural, n, separator = msgid[0], msgid[1], msgid_plural, n
|
38
|
+
separator = '|' unless separator.is_a?(::String)
|
39
|
+
end
|
40
|
+
|
41
|
+
scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
|
42
|
+
default = { :one => msgid, :other => msgid_plural }
|
43
|
+
I18n.t(msgid, :default => default, :count => n, :scope => scope, :separator => separator)
|
44
|
+
end
|
45
|
+
alias ns_ nsgettext
|
46
|
+
|
47
|
+
# Method signatures:
|
48
|
+
# npgettext('Fruits', 'apple', 'apples', 2)
|
49
|
+
# npgettext('Fruits', ['apple', 'apples'], 2)
|
50
|
+
def npgettext(msgctxt, msgid, msgid_plural, n = 1)
|
51
|
+
separator = I18n::Gettext::CONTEXT_SEPARATOR
|
52
|
+
|
53
|
+
if msgid.is_a?(Array)
|
54
|
+
msgid_plural, msgid, n = msgid[1], [msgctxt, msgid[0]].join(separator), msgid_plural
|
55
|
+
else
|
56
|
+
msgid = [msgctxt, msgid].join(separator)
|
57
|
+
end
|
58
|
+
|
59
|
+
nsgettext(msgid, msgid_plural, n, separator)
|
60
|
+
end
|
61
|
+
alias np_ npgettext
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,329 @@
|
|
1
|
+
=begin
|
2
|
+
poparser.rb - Generate a .mo
|
3
|
+
|
4
|
+
Copyright (C) 2003-2009 Masao Mutoh <mutoh at highway.ne.jp>
|
5
|
+
|
6
|
+
You may redistribute it and/or modify it under the same
|
7
|
+
license terms as Ruby.
|
8
|
+
=end
|
9
|
+
|
10
|
+
#MODIFIED
|
11
|
+
# removed include GetText etc
|
12
|
+
# added stub translation method _(x)
|
13
|
+
require 'racc/parser'
|
14
|
+
|
15
|
+
module GetText
|
16
|
+
|
17
|
+
class PoParser < Racc::Parser
|
18
|
+
|
19
|
+
def _(x)
|
20
|
+
x
|
21
|
+
end
|
22
|
+
|
23
|
+
module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry', 108
|
24
|
+
def unescape(orig)
|
25
|
+
ret = orig.gsub(/\\n/, "\n")
|
26
|
+
ret.gsub!(/\\t/, "\t")
|
27
|
+
ret.gsub!(/\\r/, "\r")
|
28
|
+
ret.gsub!(/\\"/, "\"")
|
29
|
+
ret
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse(str, data, ignore_fuzzy = true)
|
33
|
+
@comments = []
|
34
|
+
@data = data
|
35
|
+
@fuzzy = false
|
36
|
+
@msgctxt = ""
|
37
|
+
$ignore_fuzzy = ignore_fuzzy
|
38
|
+
|
39
|
+
str.strip!
|
40
|
+
@q = []
|
41
|
+
until str.empty? do
|
42
|
+
case str
|
43
|
+
when /\A\s+/
|
44
|
+
str = $'
|
45
|
+
when /\Amsgctxt/
|
46
|
+
@q.push [:MSGCTXT, $&]
|
47
|
+
str = $'
|
48
|
+
when /\Amsgid_plural/
|
49
|
+
@q.push [:MSGID_PLURAL, $&]
|
50
|
+
str = $'
|
51
|
+
when /\Amsgid/
|
52
|
+
@q.push [:MSGID, $&]
|
53
|
+
str = $'
|
54
|
+
when /\Amsgstr/
|
55
|
+
@q.push [:MSGSTR, $&]
|
56
|
+
str = $'
|
57
|
+
when /\A\[(\d+)\]/
|
58
|
+
@q.push [:PLURAL_NUM, $1]
|
59
|
+
str = $'
|
60
|
+
when /\A\#~(.*)/
|
61
|
+
$stderr.print _("Warning: obsolete msgid exists.\n")
|
62
|
+
$stderr.print " #{$&}\n"
|
63
|
+
@q.push [:COMMENT, $&]
|
64
|
+
str = $'
|
65
|
+
when /\A\#(.*)/
|
66
|
+
@q.push [:COMMENT, $&]
|
67
|
+
str = $'
|
68
|
+
when /\A\"(.*)\"/
|
69
|
+
@q.push [:STRING, $1]
|
70
|
+
str = $'
|
71
|
+
else
|
72
|
+
#c = str[0,1]
|
73
|
+
#@q.push [:STRING, c]
|
74
|
+
str = str[1..-1]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
@q.push [false, '$end']
|
78
|
+
if $DEBUG
|
79
|
+
@q.each do |a,b|
|
80
|
+
puts "[#{a}, #{b}]"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
@yydebug = true if $DEBUG
|
84
|
+
do_parse
|
85
|
+
|
86
|
+
if @comments.size > 0
|
87
|
+
@data.set_comment(:last, @comments.join("\n"))
|
88
|
+
end
|
89
|
+
@data
|
90
|
+
end
|
91
|
+
|
92
|
+
def next_token
|
93
|
+
@q.shift
|
94
|
+
end
|
95
|
+
|
96
|
+
def on_message(msgid, msgstr)
|
97
|
+
if msgstr.size > 0
|
98
|
+
@data[msgid] = msgstr
|
99
|
+
@data.set_comment(msgid, @comments.join("\n"))
|
100
|
+
end
|
101
|
+
@comments.clear
|
102
|
+
@msgctxt = ""
|
103
|
+
end
|
104
|
+
|
105
|
+
def on_comment(comment)
|
106
|
+
@fuzzy = true if (/fuzzy/ =~ comment)
|
107
|
+
@comments << comment
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
..end src/poparser.ry modeval..id7a99570e05
|
112
|
+
|
113
|
+
##### racc 1.4.5 generates ###
|
114
|
+
|
115
|
+
racc_reduce_table = [
|
116
|
+
0, 0, :racc_error,
|
117
|
+
0, 10, :_reduce_none,
|
118
|
+
2, 10, :_reduce_none,
|
119
|
+
2, 10, :_reduce_none,
|
120
|
+
2, 10, :_reduce_none,
|
121
|
+
2, 12, :_reduce_5,
|
122
|
+
1, 13, :_reduce_none,
|
123
|
+
1, 13, :_reduce_none,
|
124
|
+
4, 15, :_reduce_8,
|
125
|
+
5, 16, :_reduce_9,
|
126
|
+
2, 17, :_reduce_10,
|
127
|
+
1, 17, :_reduce_none,
|
128
|
+
3, 18, :_reduce_12,
|
129
|
+
1, 11, :_reduce_13,
|
130
|
+
2, 14, :_reduce_14,
|
131
|
+
1, 14, :_reduce_15 ]
|
132
|
+
|
133
|
+
racc_reduce_n = 16
|
134
|
+
|
135
|
+
racc_shift_n = 26
|
136
|
+
|
137
|
+
racc_action_table = [
|
138
|
+
3, 13, 5, 7, 9, 15, 16, 17, 20, 17,
|
139
|
+
13, 17, 13, 13, 11, 17, 23, 20, 13, 17 ]
|
140
|
+
|
141
|
+
racc_action_check = [
|
142
|
+
1, 16, 1, 1, 1, 12, 12, 12, 18, 18,
|
143
|
+
7, 14, 15, 9, 3, 19, 20, 21, 23, 25 ]
|
144
|
+
|
145
|
+
racc_action_pointer = [
|
146
|
+
nil, 0, nil, 14, nil, nil, nil, 3, nil, 6,
|
147
|
+
nil, nil, 0, nil, 4, 5, -6, nil, 2, 8,
|
148
|
+
8, 11, nil, 11, nil, 12 ]
|
149
|
+
|
150
|
+
racc_action_default = [
|
151
|
+
-1, -16, -2, -16, -3, -13, -4, -16, -6, -16,
|
152
|
+
-7, 26, -16, -15, -5, -16, -16, -14, -16, -8,
|
153
|
+
-16, -9, -11, -16, -10, -12 ]
|
154
|
+
|
155
|
+
racc_goto_table = [
|
156
|
+
12, 22, 14, 4, 24, 6, 2, 8, 18, 19,
|
157
|
+
10, 21, 1, nil, nil, nil, 25 ]
|
158
|
+
|
159
|
+
racc_goto_check = [
|
160
|
+
5, 9, 5, 3, 9, 4, 2, 6, 5, 5,
|
161
|
+
7, 8, 1, nil, nil, nil, 5 ]
|
162
|
+
|
163
|
+
racc_goto_pointer = [
|
164
|
+
nil, 12, 5, 2, 4, -7, 6, 9, -7, -17 ]
|
165
|
+
|
166
|
+
racc_goto_default = [
|
167
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ]
|
168
|
+
|
169
|
+
racc_token_table = {
|
170
|
+
false => 0,
|
171
|
+
Object.new => 1,
|
172
|
+
:COMMENT => 2,
|
173
|
+
:MSGID => 3,
|
174
|
+
:MSGCTXT => 4,
|
175
|
+
:MSGID_PLURAL => 5,
|
176
|
+
:MSGSTR => 6,
|
177
|
+
:STRING => 7,
|
178
|
+
:PLURAL_NUM => 8 }
|
179
|
+
|
180
|
+
racc_use_result_var = true
|
181
|
+
|
182
|
+
racc_nt_base = 9
|
183
|
+
|
184
|
+
Racc_arg = [
|
185
|
+
racc_action_table,
|
186
|
+
racc_action_check,
|
187
|
+
racc_action_default,
|
188
|
+
racc_action_pointer,
|
189
|
+
racc_goto_table,
|
190
|
+
racc_goto_check,
|
191
|
+
racc_goto_default,
|
192
|
+
racc_goto_pointer,
|
193
|
+
racc_nt_base,
|
194
|
+
racc_reduce_table,
|
195
|
+
racc_token_table,
|
196
|
+
racc_shift_n,
|
197
|
+
racc_reduce_n,
|
198
|
+
racc_use_result_var ]
|
199
|
+
|
200
|
+
Racc_token_to_s_table = [
|
201
|
+
'$end',
|
202
|
+
'error',
|
203
|
+
'COMMENT',
|
204
|
+
'MSGID',
|
205
|
+
'MSGCTXT',
|
206
|
+
'MSGID_PLURAL',
|
207
|
+
'MSGSTR',
|
208
|
+
'STRING',
|
209
|
+
'PLURAL_NUM',
|
210
|
+
'$start',
|
211
|
+
'msgfmt',
|
212
|
+
'comment',
|
213
|
+
'msgctxt',
|
214
|
+
'message',
|
215
|
+
'string_list',
|
216
|
+
'single_message',
|
217
|
+
'plural_message',
|
218
|
+
'msgstr_plural',
|
219
|
+
'msgstr_plural_line']
|
220
|
+
|
221
|
+
Racc_debug_parser = true
|
222
|
+
|
223
|
+
##### racc system variables end #####
|
224
|
+
|
225
|
+
# reduce 0 omitted
|
226
|
+
|
227
|
+
# reduce 1 omitted
|
228
|
+
|
229
|
+
# reduce 2 omitted
|
230
|
+
|
231
|
+
# reduce 3 omitted
|
232
|
+
|
233
|
+
# reduce 4 omitted
|
234
|
+
|
235
|
+
module_eval <<'.,.,', 'src/poparser.ry', 25
|
236
|
+
def _reduce_5( val, _values, result )
|
237
|
+
@msgctxt = unescape(val[1]) + "\004"
|
238
|
+
result
|
239
|
+
end
|
240
|
+
.,.,
|
241
|
+
|
242
|
+
# reduce 6 omitted
|
243
|
+
|
244
|
+
# reduce 7 omitted
|
245
|
+
|
246
|
+
module_eval <<'.,.,', 'src/poparser.ry', 48
|
247
|
+
def _reduce_8( val, _values, result )
|
248
|
+
if @fuzzy and $ignore_fuzzy
|
249
|
+
if val[1] != ""
|
250
|
+
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
251
|
+
$stderr.print " msgid '#{val[1]}'\n"
|
252
|
+
else
|
253
|
+
on_message('', unescape(val[3]))
|
254
|
+
end
|
255
|
+
@fuzzy = false
|
256
|
+
else
|
257
|
+
on_message(@msgctxt + unescape(val[1]), unescape(val[3]))
|
258
|
+
end
|
259
|
+
result = ""
|
260
|
+
result
|
261
|
+
end
|
262
|
+
.,.,
|
263
|
+
|
264
|
+
module_eval <<'.,.,', 'src/poparser.ry', 65
|
265
|
+
def _reduce_9( val, _values, result )
|
266
|
+
if @fuzzy and $ignore_fuzzy
|
267
|
+
if val[1] != ""
|
268
|
+
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
269
|
+
$stderr.print "msgid = '#{val[1]}\n"
|
270
|
+
else
|
271
|
+
on_message('', unescape(val[3]))
|
272
|
+
end
|
273
|
+
@fuzzy = false
|
274
|
+
else
|
275
|
+
on_message(@msgctxt + unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4]))
|
276
|
+
end
|
277
|
+
result = ""
|
278
|
+
result
|
279
|
+
end
|
280
|
+
.,.,
|
281
|
+
|
282
|
+
module_eval <<'.,.,', 'src/poparser.ry', 76
|
283
|
+
def _reduce_10( val, _values, result )
|
284
|
+
if val[0].size > 0
|
285
|
+
result = val[0] + "\000" + val[1]
|
286
|
+
else
|
287
|
+
result = ""
|
288
|
+
end
|
289
|
+
result
|
290
|
+
end
|
291
|
+
.,.,
|
292
|
+
|
293
|
+
# reduce 11 omitted
|
294
|
+
|
295
|
+
module_eval <<'.,.,', 'src/poparser.ry', 84
|
296
|
+
def _reduce_12( val, _values, result )
|
297
|
+
result = val[2]
|
298
|
+
result
|
299
|
+
end
|
300
|
+
.,.,
|
301
|
+
|
302
|
+
module_eval <<'.,.,', 'src/poparser.ry', 91
|
303
|
+
def _reduce_13( val, _values, result )
|
304
|
+
on_comment(val[0])
|
305
|
+
result
|
306
|
+
end
|
307
|
+
.,.,
|
308
|
+
|
309
|
+
module_eval <<'.,.,', 'src/poparser.ry', 99
|
310
|
+
def _reduce_14( val, _values, result )
|
311
|
+
result = val.delete_if{|item| item == ""}.join
|
312
|
+
result
|
313
|
+
end
|
314
|
+
.,.,
|
315
|
+
|
316
|
+
module_eval <<'.,.,', 'src/poparser.ry', 103
|
317
|
+
def _reduce_15( val, _values, result )
|
318
|
+
result = val[0]
|
319
|
+
result
|
320
|
+
end
|
321
|
+
.,.,
|
322
|
+
|
323
|
+
def _reduce_none( val, _values, result )
|
324
|
+
result
|
325
|
+
end
|
326
|
+
|
327
|
+
end # class PoParser
|
328
|
+
|
329
|
+
end # module GetText
|