-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for FastGettext 2.0 (bsc#1121865)
(backward compatible with FastGettext 1.6)
- Loading branch information
Showing
11 changed files
with
127 additions
and
8 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 |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/build | ||
/.yardoc | ||
/package/*.tar.* | ||
*.pot |
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
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
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
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
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,9 @@ | ||
require "fast_gettext" | ||
|
||
module Yast | ||
# Just a wrapper around FastGettext::Translation, we cannot include it | ||
# directly because we define our own _() and n_() methods. | ||
module Translation | ||
extend FastGettext::Translation | ||
end | ||
end |
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
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
Binary file not shown.
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,34 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR SuSE Linux Products GmbH, Nuernberg | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
# Run this command to compile itto an .mo file: | ||
# msgfmt -o LC_MESSAGES/example.mo example.po | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-01-22 14:06+0100\n" | ||
"PO-Revision-Date: 2019-01-22 14:06+0100\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <LL@li.org>\n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" | ||
|
||
#. set the Czech language for these tests | ||
#: tests/integration/translations.rb:18 tests/integration/translations.rb:26 | ||
msgid "Example" | ||
msgstr "Příklad" | ||
|
||
#: tests/integration/translations.rb:22 | ||
msgid "%s Example" | ||
msgid_plural "%s Examples" | ||
msgstr[0] "%s Příklad" | ||
msgstr[1] "%s Příklady" | ||
msgstr[2] "%s Příkladů" |
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,71 @@ | ||
#! /usr/bin/env rspec | ||
|
||
require_relative "../test_helper" | ||
|
||
require "yast" | ||
|
||
# set the Czech language for these tests | ||
ENV["LC_ALL"] = "cs_CZ.UTF-8" | ||
|
||
class TranslationExample | ||
include Yast::I18n | ||
|
||
def initialize | ||
textdomain "example" | ||
end | ||
|
||
def translation_simple | ||
_("Example") | ||
end | ||
|
||
def translation_plural(n) | ||
format(n_("%s Example", "%s Examples", n), n) | ||
end | ||
|
||
def translation_mark | ||
N_("Example") | ||
end | ||
|
||
def translation_mark_plural(n) | ||
Nn_("%s Example", "%s Examples", n) | ||
end | ||
end | ||
|
||
describe "translations in YaST" do | ||
subject { TranslationExample.new } | ||
|
||
before do | ||
# override the default path with translations | ||
stub_const("Yast::I18n::LOCALE_DIR", File.expand_path("../locale", __FILE__)) | ||
end | ||
|
||
it "translates string using _()" do | ||
expect(subject.translation_simple).to eq("Příklad") | ||
end | ||
|
||
it "translates plural string using n_() with 0 value" do | ||
expect(subject.translation_plural(0)).to eq("0 Příkladů") | ||
end | ||
|
||
it "translates plural string using n_() with 1 value" do | ||
expect(subject.translation_plural(1)).to eq("1 Příklad") | ||
end | ||
|
||
it "translates plural string using n_() with 2 value" do | ||
expect(subject.translation_plural(2)).to eq("2 Příklady") | ||
end | ||
|
||
it "translates plural string using n_() with 5 value" do | ||
expect(subject.translation_plural(5)).to eq("5 Příkladů") | ||
end | ||
|
||
|
||
it "does not translate string using N_()" do | ||
expect(subject.translation_mark).to eq("Example") | ||
end | ||
|
||
it "does not translate string using Nn_()" do | ||
expect(subject.translation_mark_plural(0)).to eq(["%s Example", "%s Examples", 0]) | ||
end | ||
|
||
end |