Skip to content

Commit

Permalink
Merge pull request #103 from yast/N_
Browse files Browse the repository at this point in the history
added N_() and Nn_() gettext equivalents
  • Loading branch information
lslezak committed Feb 26, 2014
2 parents f9cfe23 + 6f37329 commit 865f364
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
7 changes: 7 additions & 0 deletions package/yast2-ruby-bindings.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Feb 26 12:22:48 UTC 2014 - lslezak@suse.cz

- added N_() and Nn_() gettext equivalents (to only mark a text
for translation)
- 3.1.12

-------------------------------------------------------------------
Thu Feb 20 07:58:32 UTC 2014 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-ruby-bindings.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-ruby-bindings
Version: 3.1.11
Version: 3.1.12
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: yast2-ruby-bindings-%{version}.tar.bz2
Expand Down
12 changes: 12 additions & 0 deletions src/ruby/yast/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ def _(str)
FastGettext.text_domain = old_text_domain
end

# No translation, only marks the text to be found by gettext when creating POT file,
# the text needs to be translated by _() later.
def N_(str)
str
end

# No translation, only marks the texts to be found by gettext when creating POT file,
# the texts need to be translated by n_() later.
def Nn_(*keys)
keys
end

# Gets translation based on number.
# @param (String) singular text for translators for single value
# @param (String) plural text for translators for bigger value
Expand Down
30 changes: 30 additions & 0 deletions tests/ruby/i18n_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env rspec

require_relative "test_helper_rspec"

require "yast"

include Yast::I18n

module Yast
describe I18n do

describe ".N_" do
it "returns the original parameter" do
input = "INPUT TEST"
expect(N_(input)).to be input
end
end

describe ".Nn_" do
it "returns the original parameters" do
singular = "singular"
plural = "plural"
count = 42

expect(Nn_(singular, plural, count)).to eq [singular, plural, count]
end
end

end
end

0 comments on commit 865f364

Please sign in to comment.