Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added N_() and Nn_() gettext equivalents #103

Merged
merged 1 commit into from
Feb 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I read this spec it can make effect that it is useless. Maybe you try call gettext and verify that it is in POT.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is useless 😄 , it has only a side effect for gettext when creating POT...

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