Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
136 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
|
||
"""Test input for Babel""" | ||
|
||
|
||
from oslo.i18n import _ | ||
from oslo.i18n import _LE | ||
from oslo_log import log as logging | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
def just_testing(): | ||
"""Just some random commands for Babel to extract strings from""" | ||
|
||
LOG.exception(_LE("LE translated string1")) | ||
LOG.exception(_LE("LE translated string2")) | ||
print(_("Normal translated string1")) | ||
# Translators: Comment for string2 | ||
print(_("Normal translated string2")) |
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,28 @@ | ||
# Translations template for requirements. | ||
# Copyright (C) 2016 ORGANIZATION | ||
# This file is distributed under the same license as the requirements | ||
# project. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2016. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: requirements 1\n" | ||
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/openstack-i18n/\n" | ||
"POT-Creation-Date: 2016-04-24 09:28+0200\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <LL@li.org>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: Babel 1.3\n" | ||
|
||
#: babel-test/babel-input.py:24 | ||
msgid "LE translated string1" | ||
msgstr "" | ||
|
||
#: babel-test/babel-input.py:25 | ||
msgid "LE translated string2" | ||
msgstr "" | ||
|
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,29 @@ | ||
# Translations template for requirements. | ||
# Copyright (C) 2016 ORGANIZATION | ||
# This file is distributed under the same license as the requirements | ||
# project. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2016. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: requirements 1\n" | ||
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/openstack-i18n/\n" | ||
"POT-Creation-Date: 2016-04-24 09:28+0200\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <LL@li.org>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: Babel 1.3\n" | ||
|
||
#: babel-test/babel-input.py:26 | ||
msgid "Normal translated string1" | ||
msgstr "" | ||
|
||
#. Translators: Comment for string2 | ||
#: babel-test/babel-input.py:28 | ||
msgid "Normal translated string2" | ||
msgstr "" | ||
|
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,42 @@ | ||
#!/bin/bash -xe | ||
|
||
pybabel extract \ | ||
--add-comments Translators: \ | ||
--msgid-bugs-address="https://bugs.launchpad.net/openstack-i18n/" \ | ||
--project=requirements --version=1 \ | ||
-k "_C:1c,2" -k "_P:1,2" \ | ||
-o babel-test/test.pot babel-test | ||
|
||
pybabel extract --no-default-keywords \ | ||
--add-comments Translators: \ | ||
--msgid-bugs-address="https://bugs.launchpad.net/openstack-i18n/" \ | ||
--project=requirements --version=1 \ | ||
-k "_LE" \ | ||
-o babel-test/test-log-error.pot babel-test | ||
|
||
# Entries to ignore | ||
REGEX="(POT-Creation-Date|Generated-By|Copyright (C) |FIRST AUTHOR <EMAIL@ADDRESS>)" | ||
|
||
function diff_files { | ||
local expected=$1 | ||
local testfile=$2 | ||
local extra | ||
|
||
# grep fails if there's no content - which is fine here. | ||
set +e | ||
extra=$(diff -u0 $expected $testfile | \ | ||
egrep -v "$REGEX" |egrep -c "^([-+][^-+#])") | ||
set -e | ||
|
||
if [ $extra -ne 0 ] ; then | ||
echo "Generation of test.pot failed." | ||
echo "Extra content is:" | ||
diff -u0 $expected $testfile | egrep -v "$REGEX" | ||
exit 1 | ||
fi | ||
} | ||
|
||
diff_files babel-test/expected.pot babel-test/test.pot | ||
diff_files babel-test/expected-log-error.pot babel-test/test-log-error.pot | ||
|
||
echo "Everything fine" |
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