TerraLib and TerraView Wiki Page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:documentation:devguide:core:translator [2016/10/04 08:55]
carolina.santos [Referências]
wiki:documentation:devguide:core:translator [2016/11/04 08:32] (current)
carolina.santos [CMake]
Line 7: Line 7:
 Translation dictionaries are sets of textual and binary files that are created through the [[https://​www.gnu.org/​software/​gettext/​ | GNU Gettext]] tools. Translation dictionaries are sets of textual and binary files that are created through the [[https://​www.gnu.org/​software/​gettext/​ | GNU Gettext]] tools.
  
-The translation is not automatic, it is necessary to perform this process manually in the files "​po"​.+The translation is not automatic, it is necessary to perform this process manually in the "​po" ​files.
 ===== API ===== ===== API =====
  
Line 24: Line 24:
       \brief This singleton is designed to deal with multi-language text translation in TerraLib.       \brief This singleton is designed to deal with multi-language text translation in TerraLib.
      */      */
-    class TECOREEXPORT ​Translator+    class Translator
     {     {
  
Line 158: Line 158:
 To facilitate the creation of binary files containing the translated messages as well as their inclusion in the binary distribution of packages in TerraLib family applications,​ the macro **TERRALIB_REGISTER_TRANSLATION** was created in CMake to be able to automate this process. This macro is in //​build/​cmake/​terralib_macros.cmake//​ file in the code repository. To facilitate the creation of binary files containing the translated messages as well as their inclusion in the binary distribution of packages in TerraLib family applications,​ the macro **TERRALIB_REGISTER_TRANSLATION** was created in CMake to be able to automate this process. This macro is in //​build/​cmake/​terralib_macros.cmake//​ file in the code repository.
  
-All TerraLib libraries that need the message translation system should use the above macro in your build project files (//​CMakeLists.txt//​). It has the following form:+All TerraLib libraries that need the message translation system should use the above macro in their build project files (//​CMakeLists.txt//​), in the following form:
  
 <code cpp> <code cpp>
Line 180: Line 180:
  
  
-===== Exemplos ​=====+===== Examples ​=====
  
-Os arquivos ​"​.po" ​podem ser criados na linha de comando com as ferramentas da [[https://​www.gnu.org/​software/​gettext/​ | GNU Gettext]] ​ou através de ferramentas gráficas como o [[https://​poeditor.com/​ | ​POEditor]] ​ou o [[https://​poedit.net/​download | Poedit]].+The files "​.po" ​can be created from the command line with the tools of [[https://​www.gnu.org/​software/​gettext/​ | GNU Gettext]] ​or through graphical tools like [[https://​poeditor.com/​ | ​POEditor]] ​or [[https://​poedit.net/​download | Poedit]].
  
-A seguiriremos mostrar como criar esses arquivos na linha de comando com as ferramentas da [[https://​www.gnu.org/​software/​gettext/​ | GNU Gettext]].+Nextwe will show how to create these files on the command line with [[https://​www.gnu.org/​software/​gettext/​ | GNU Gettext]] ​tools.
  
-Para começar um novo arquivo de tradução, primeiramentetemos que criar um arquivo com extensão ​"​.pot", ​que conterá um template ​das mensagens identificadas no código fonteO comando a seguir mostra como extrair as mensagens dos arquivos informados:+To start a new translation filefirst we have to create ​file with the extension ​"​.pot", ​which contains a template ​of the messages identified in the source codeThe following command shows how to extract messages from the reported files:
  
 <code cpp> <code cpp>
Line 192: Line 192:
 </​code>​ </​code>​
  
-O comando acima irá produzir o arquivo ​//​terralib_unittest_core.pot//​.+The above command will produce the file //​terralib_unittest_core.pot//​.
  
-Caso você ainda não tenha um arquivo com extensão ​"​.po", ​no caso da criação de novas bibliotecas,​ utilize o comando abaixo para criar este arquivo onde deverão ser incluídas as traduções para um determinado idioma:+If you do not already have file with the extension ​"​.po" ​in the case of creating new librariesuse the following command to create this file where should be included the translations for a particular language:
  
 <code cpp> <code cpp>
Line 200: Line 200:
 </​code>​ </​code>​
  
-O comando acima irá produzir o arquivo ​//​terralib_unittest_core_pt_BR.po//​.+The above command will produce the file //​terralib_unittest_core_pt_BR.po//​.
  
-Caso você já possua um arquivo ​"​.po" ​e deseje apenas realizar uma atualização do mesmovocê pode fazer isso através ​do seguinte comando:+If you already have a file "​.po" ​and just want to perform an updateyou can do this using the following command:
  
 <code cpp> <code cpp>
Line 210: Line 210:
 </​code>​ </​code>​
  
-**Nota:** No comando ​xgettext, onde você está atualizando o arquivo ​template, ​você pode informar novos arquivos se necessário.+**Note:** In xgettext ​command where you are upgrading the template ​fileyou can enter new files if necessary.
  
-A criação dos arquivo binários com a extensão ​"​.mo", ​contendo as traduções para uso nos sistemasé feita de forma automática no build através da macro **TERRALIB_REGISTER_TRANSLATION**. ​Para isso, acrescente no seu //​CMakeLists.txt// ​o registro de traduções como mostrado abaixo:+The creation of the binary files with the extension ​"​.mo", ​containing translations to use in the systemsis done automatically in the build through the macro **TERRALIB_REGISTER_TRANSLATION**. ​Add to your //​CMakeLists.txt// ​the record of translations as shown below:
  
 <code cpp> <code cpp>
Line 220: Line 220:
 </​code>​ </​code>​
  
-**Nota:** utilizar o mesmo nome da biblioteca ou executável no registro de sua tradução.+**Note:** use the same name as the library or executable in the record of your translation.
  
-No seu código fonte inclua uma chamada à macro **TE_ADD_TEXT_DOMAIN** ​para adicionar em tempo de execução o seu arquivo de traduçãoVeja o exemplo abaixo:+In your source code include a call to the macro **TE_ADD_TEXT_DOMAIN** ​to add at runtime your translation fileSee the example below:
  
 <code cpp> <code cpp>
Line 244: Line 244:
 </​code>​ </​code>​
  
-Uma vez que o arquivo de tradução encontra-se carregadoas macros **TE_TR** ​**TE_TR_PLURAL** ​irão produzir a tradução correta:+Once the translation file is loaded, macros **TE_TR** ​and **TE_TR_PLURAL** ​will produce the correct translation:
  
 <code cpp> <code cpp>
Line 275: Line 275:
  
  
-===== References =====+===== Additional ​References =====
  
   * [[http://​www.boost.org/​doc/​libs/​1_56_0/​libs/​locale/​doc/​html/​messages_formatting.html | Boost.Locale - Messages Formatting (Translation)]]   * [[http://​www.boost.org/​doc/​libs/​1_56_0/​libs/​locale/​doc/​html/​messages_formatting.html | Boost.Locale - Messages Formatting (Translation)]]