## The module "gettext" of the Mastrave modelling library

Daniele de Rigo

The file gettext.m is part of Mastrave.

Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Mastrave. If not, see http://www.gnu.org/licenses/.

#### Function declaration

  answer = gettext( text_key      ,
language = [] ,
country  = [] ,
package  = [] )



#### Description

Utility to implement within Mastrave an equivalent of GNU gettext. If the function is called passing only the text_key argument, it returns the translation of text_key in the currently set language. If the desired translation is not available, text_key will be returned.

Usually, text_key is an English word or statement to ensure a wide understandability of Mastrave and MastraveFKP messages even without any available translation. In case of English homonyms that are not homonyms in other languages, it is possible to disambiguate them by passing as text_key a cell array of two strings whose first element is the text to be translated and the second one is a comment providing some information for translators.

If more than one argument is passed, the function will perform the action specified in text_key using the internationalization support of Mastrave or of the MastraveFKP package for the language dialect which is used in country .

If the action '--scan' is passed, the function analyses all files within package assuming that they conform to Mastrave coding standards, to create or update the corresponding internationalization support for the language dialect used in country .

Input argument:

text_key ::cellstring::
String to be used as output in an human language
(technical strings such as the declaration of some
function have not to be translated).
In case of possible homonyms, text_key can be passed
as a cell-array of two strings whose first element is
the text to be translated and the second one provides
some information for translators.

If more than one argument is passed, text_key assumes
a special meaning which define the action to be
performed with the subsequent arguments.
Valid special values are:

action | meaning
----------+--------------------------------------------
'--use' | Switch to the passed values of language
| and country : subsequent calls to
| gettext will return the corresponding
| translation in the language dialect
| which is used in country .
----------+--------------------------------------------
'--scan' | Scan all files of Mastrave or of the
| MastraveFKP package to create the
| internationalization support for the
| language dialect used in country .
----------+-------------------------------------------
'--path' | Return the path of the file implementing
| the internationalization support for
| package in the language dialect which
| is used in country .

language ::string::
ISO 639-1 alpha-2 code of language.
If omitted, the default value is [] (empty).
If empty, the string 'en' is used.

country ::string::
ISO 3166-1 alpha-2 code of country.
If omitted, the default value is [] (empty).
If empty, the string 'US' is used.

package ::string::
If omitted, the default value is [] (empty).
If empty, the string '' is used.

Output argument:

Examples of usage:

gettext( '--use' , 'it' , 'IT' )
fprintf( 1 , gettext( 'hello Mastrave world!' ) )

gettext( '--scan' , 'it' , 'IT' )

txt_justify

Keywords:
internationalization, string, help

Version: 0.0.28

#### Input arguments

Utility to implement within Mastrave an equivalent of GNU gettext.
If the function is called passing only the  text_key  argument, it returns
the translation of  text_key  in the currently set language.
If the desired translation is not available,  text_key  will be returned.

Usually,  text_key  is an English word or statement to ensure a wide
understandability of Mastrave and MastraveFKP messages even without any
available translation.
In case of English homonyms that are not homonyms in other languages, it
is possible to disambiguate them by passing as  text_key  a cell array of
two strings whose first element is the text to be translated and the
second one is a comment providing some information for translators.

If more than one argument is passed, the function will perform the
action specified in  text_key  using the internationalization support
of Mastrave or of the MastraveFKP  package  for the  language  dialect
which is used in  country .

If the action '--scan' is passed, the function analyses all files within
package  assuming that they conform to Mastrave coding standards, to create
or update the corresponding internationalization support for the  language
dialect used in  country .

Input argument:

text_key           ::cellstring::
String to be used as output in an human language
(technical strings such as the declaration of some
function have not to be translated).
In case of possible homonyms,  text_key  can be passed
as a cell-array of two strings whose first element is
the text to be translated and the second one provides
some information for translators.

If more than one argument is passed,  text_key  assumes
a special meaning which define the action to be
performed with the subsequent arguments.
Valid special values are:

action  │       meaning
──────────┼────────────────────────────────────────────
'--use'  │ Switch to the passed values of  language
│ and  country : subsequent calls to
│ gettext will return the corresponding
│ translation in the  language  dialect
│ which is used in  country .
──────────┼────────────────────────────────────────────
'--scan' │ Scan all files of Mastrave or of the
│ MastraveFKP  package  to create the
│ internationalization support for the
│  language  dialect used in  country .
──────────┼───────────────────────────────────────────
'--path' │ Return the path of the file implementing
│ the internationalization support for
│  package  in the  language  dialect which
│ is used in  country .

language           ::string::
ISO 639-1 alpha-2 code of language.
If omitted, the default value is  [] (empty).
If empty, the string 'en' is used.

country            ::string::
ISO 3166-1 alpha-2 code of country.
If omitted, the default value is  [] (empty).
If empty, the string 'US' is used.

package            ::string::
If omitted, the default value is  [] (empty).
If empty, the string '' is used.

Output argument:



#### Example of usage


gettext( '--use' , 'it' , 'IT' )
fprintf( 1 , gettext( 'hello Mastrave world!' ) )

gettext( '--scan' , 'it' , 'IT' )


See also:
txt_justify

Keywords:
internationalization, string, help

Version: 0.0.28

#### Support

The Mastrave modelling library is committed to provide reusable and general - but also robust and scalable - modules for research modellers dealing with computational science.  You can help the Mastrave project by providing feedbacks on unexpected behaviours of this module.  Despite all efforts, all of us - either developers or users - (should) know that errors are unavoidable.  However, the free software paradigm successfully highlights that scientific knowledge freedom also implies an impressive opportunity for collectively evolve the tools and ideas upon which our daily work is based.  Reporting a problem that you found using Mastrave may help the developer team to find a possible bug.  Please, be aware that Mastrave is entirely based on voluntary efforts: in order for your help to be as effective as possible, please read carefully the section on reporting problems.  Thank you for your collaboration.

Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Daniele de Rigo