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

gettext/library #2

Merged
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
9 changes: 8 additions & 1 deletion recipes/gettext/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,22 @@ def build(self):

def package(self):
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
self.copy(pattern="*.dll", dst="bin", src=self._source_subfolder, keep_path=False, symlinks=True)
self.copy(pattern="*.lib", dst="lib", src=self._source_subfolder, keep_path=False, symlinks=True)
self.copy(pattern="*.a", dst="lib", src=self._source_subfolder, keep_path=False, symlinks=True)
self.copy(pattern="*.so*", dst="lib", src=self._source_subfolder, keep_path=False, symlinks=True)
self.copy(pattern="*.dylib*", dst="lib", src=self._source_subfolder, keep_path=False, symlinks=True)

with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():
with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op():
with tools.chdir(os.path.join(self._source_subfolder)):
env_build = self._configure_autotools()
env_build.install()
tools.rmdir(os.path.join(self.package_folder, 'share'))
self.copy(pattern="*libgnuintl.h", dst="include", src=self._source_subfolder, keep_path=False, symlinks=True)
os.rename(os.path.join(self.package_folder, "include", "libgnuintl.h"),
os.path.join(self.package_folder, "include", "libintl.h"))

tools.rmdir(os.path.join(self.package_folder, 'share'))
for f in glob.glob(os.path.join(self.package_folder, "lib", "*.la")):
os.remove(f)

Expand Down
10 changes: 10 additions & 0 deletions recipes/gettext/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8.12)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

find_package(gettext)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} gettext::gettext)
31 changes: 26 additions & 5 deletions recipes/gettext/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
from conans import ConanFile
import os
import shutil
from conans import ConanFile, CMake, tools


class TestPackageConan(ConanFile):
settings = "os", "arch"
generators = "txt"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
for locale in ["en", "ru", "es"]:
directory = os.path.join(self.source_folder, locale, "LC_MESSAGES")
if not os.path.isdir(directory):
os.makedirs(directory)
shutil.copy(os.path.join(self.source_folder, "po", locale, "conan.mo.workaround_git_ignore"),
os.path.join(self.source_folder, locale, "LC_MESSAGES", "conan.mo"))

def test(self):
for exe in ['gettext', 'ngettext', 'msgcat', 'msgmerge']:
self.run("%s --version" % exe, run_environment=True)
if not tools.cross_building(self.settings):
self.output.info("Check working executables")
for exe in ['gettext', 'ngettext', 'msgcat', 'msgmerge']:
self.run("%s --version" % exe, run_environment=True)

self.output.info("Check working library")
bin_path = os.path.join("bin", "test_package")
for locale in ["en_US", "ru_RU", "es_ES"]:
with tools.environment_append({"LANG": locale}):
self.run("%s %s" % (bin_path, os.path.abspath(self.source_folder)), run_environment=True)
Binary file not shown.
23 changes: 23 additions & 0 deletions recipes/gettext/all/test_package/po/en/conan.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Conan 1.0.
# Copyright (C) Bincrafters
# This file is distributed under the same license as the Conan package.
# Bincrafters <bincrafters@gmail.com>, 2019.
msgid ""
msgstr ""
"Project-Id-Version: conan 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-11 03:48-0700\n"
"PO-Revision-Date: 2019-07-11 03:57-0700\n"
"Last-Translator: U-DESKTOP-HHN0EAP\\sse4 <sse4@desktop-hhn0eap>\n"
"Language-Team: English\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. Example of i18n usage
#: hello.c:17
#, c-format
msgid "hello"
msgstr "hello"
Binary file not shown.
23 changes: 23 additions & 0 deletions recipes/gettext/all/test_package/po/es/conan.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Conan 1.0.
# Copyright (C) Bincrafters
# This file is distributed under the same license as the Conan package.
# Bincrafters <bincrafters@gmail.com>, 2019.
msgid ""
msgstr ""
"Project-Id-Version: conan 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-11 03:48-0700\n"
"PO-Revision-Date: 2019-07-11 03:58-0700\n"
"Last-Translator: U-DESKTOP-HHN0EAP\\sse4 <sse4@desktop-hhn0eap>\n"
"Language-Team: Spanish\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. Example of i18n usage
#: hello.c:17
#, c-format
msgid "hello"
msgstr "holla"
Binary file not shown.
24 changes: 24 additions & 0 deletions recipes/gettext/all/test_package/po/ru/conan.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Conan 1.0.
# Copyright (C) Bincrafters
# This file is distributed under the same license as the Conan package.
# Bincrafters <bincrafters@gmail.com>, 2019.
msgid ""
msgstr ""
"Project-Id-Version: conan 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-11 03:48-0700\n"
"PO-Revision-Date: 2019-07-11 03:58-0700\n"
"Last-Translator: U-DESKTOP-HHN0EAP\\sse4 <sse4@desktop-hhn0eap>\n"
"Language-Team: Russian\n"
"Language: ru\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%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"

#. Example of i18n usage
#: hello.c:17
#, c-format
msgid "hello"
msgstr "privet"
26 changes: 26 additions & 0 deletions recipes/gettext/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <libintl.h>

int main(int argc, char * const argv[])
{
if (argc < 2)
return -1;
if(!bindtextdomain("conan", argv[1]))
{
printf("Warning: Could not bind text domain\n");
}
if(!textdomain("conan"))
{
printf("Warning: Could not set text domain\n");
}
if(!setlocale(LC_ALL, ""))
{
printf("Warning: could not set locale\n");
}
const char * lang = getenv("LANG");
lang = lang ? lang : "";
printf("hello in %s: %s\n", lang, gettext("hello"));
return 0;
}