TsTranslator.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/unittest/core/translator/TsTranslator.cpp
22 
23  \brief A test suit for the TerraLib Core Translator Module.
24 
25  \author Matheus Cavassan Zaglia.
26  */
27 
28 // STL
29 // TerraLib
33 
34 // Boost
35 #include <boost/test/unit_test.hpp>
36 
37 BOOST_AUTO_TEST_SUITE(translator_test_case)
38 
39 BOOST_AUTO_TEST_CASE(translator_test)
40 {
41  BOOST_CHECK_NO_THROW(TE_ADD_TEXT_DOMAIN("terralib_unittest_core", te::core::FindInTerraLibPath("share/terralib/translations")));
42  BOOST_CHECK_THROW(TE_ADD_TEXT_DOMAIN("terralib_unittest_core", te::core::FindInTerraLibPath("share/terralib/translations")), te::core::Exception);
43  BOOST_CHECK_NO_THROW(TE_TR_LANGUAGE("pt_BR"));
44  BOOST_CHECK_EQUAL(TE_TR("BR-GIS"), "SIG-BR");
45  BOOST_CHECK_EQUAL(TE_TR("Wrong cryptographer algorithm type!"), "O tipo de algoritmo de criptografia está errado!");
46  BOOST_CHECK_EQUAL(TE_TR("You must specify a logger configuration file!"), "Você deve especificar o arquivo de configuração do logger!");
47  BOOST_CHECK_EQUAL(TE_TR("It was not possible to initialize the the logger!"), "Não foi possível inicializar o logger!");
48  BOOST_CHECK_EQUAL(TE_TR("Invalid logger configuration type!"), "Tipo de configuração inválido para o logger!");
49  BOOST_CHECK_EQUAL(TE_TR("The logger name is empty!"), "O nome do logger está vazio!");
50  BOOST_CHECK_EQUAL(TE_TR("TerraLib Core Initialized!"), "O módulo Core do TerraLib foi inicializado!");
51  BOOST_CHECK_EQUAL(TE_TR("TerraLib Core Finalized!"), "O módulo Core do TerraLib foi finalizado!");
52  BOOST_CHECK_EQUAL(TE_TR("The text domain already exist."), "Text domain já existente.");
53  BOOST_CHECK_EQUAL(TE_TR("The text domain doesn't exist."), "O text domain informado não existe.");
54 // test un-translated messages
55  BOOST_CHECK_EQUAL(TE_TR("The unprepared english text will remain the same."), "The unprepared english text will remain the same.");
56 
57 // test plural messages
58  BOOST_CHECK_EQUAL(TE_TR_PLURAL("1 layer is selected.","2 layers are selected.", 2), "2 camadas estão selecionadas.");
59  BOOST_CHECK_EQUAL(TE_TR_PLURAL("1 layer is selected.","2 layers are selected.", 1), "1 camada está selecionada.");
60 
61  return ;
62 }
63 BOOST_AUTO_TEST_SUITE_END()
64 
BOOST_AUTO_TEST_SUITE(translator_test_case) BOOST_AUTO_TEST_CASE(translator_test)
This file is a wrapper around platform specific include files.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
#define TE_TR_LANGUAGE(locale)
It sets the locale for the Translator.
Definition: Translator.h:278
#define TE_ADD_TEXT_DOMAIN(domain, dir)
It adds the given text domain and its directory to the multilingual system.
Definition: Translator.h:225
This class is designed for dealing with multi-language text translation in TerraLib.
TECOREEXPORT std::string FindInTerraLibPath(const std::string &path)
Returns the path relative to a directory or file in the context of TerraLib.
BOOST_AUTO_TEST_CASE(encoding_test_utf8_latin1)
#define TE_TR_PLURAL(message1, message2, n)
It marks a string in order to get translated according to plural form.
Definition: Translator.h:269
Base exception class for TerraLib Core Runtime Library.
Exception classes for the TerraLib Core Runtime Library.