From 6f37329f9313283b60ee23937dd01db04a8765ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Wed, 26 Feb 2014 13:43:30 +0100 Subject: [PATCH] added N_() and Nn_() gettext equivalents - to only mark a text for translation - 3.1.12 --- package/yast2-ruby-bindings.changes | 7 +++++++ package/yast2-ruby-bindings.spec | 2 +- src/ruby/yast/i18n.rb | 12 ++++++++++++ tests/ruby/i18n_spec.rb | 30 +++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 tests/ruby/i18n_spec.rb diff --git a/package/yast2-ruby-bindings.changes b/package/yast2-ruby-bindings.changes index 3f018142..a3a50bbb 100644 --- a/package/yast2-ruby-bindings.changes +++ b/package/yast2-ruby-bindings.changes @@ -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 diff --git a/package/yast2-ruby-bindings.spec b/package/yast2-ruby-bindings.spec index 5a3c3e7a..b7fb1bc8 100644 --- a/package/yast2-ruby-bindings.spec +++ b/package/yast2-ruby-bindings.spec @@ -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 diff --git a/src/ruby/yast/i18n.rb b/src/ruby/yast/i18n.rb index 6ba96800..8aeb1539 100644 --- a/src/ruby/yast/i18n.rb +++ b/src/ruby/yast/i18n.rb @@ -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 diff --git a/tests/ruby/i18n_spec.rb b/tests/ruby/i18n_spec.rb new file mode 100755 index 00000000..acebee95 --- /dev/null +++ b/tests/ruby/i18n_spec.rb @@ -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