Atualizar fork

This commit is contained in:
BrunoMine 2016-08-10 16:25:29 -03:00
parent a517711226
commit 6cfe392b82
3 changed files with 264 additions and 68 deletions

136
README-es_UY.md Normal file
View File

@ -0,0 +1,136 @@
# Biblioteca de Internacionalización para Minetest
Por Diego Martínez (kaeza).
Lanzada bajo WTFPL.
Éste mod es un intento de proveer soporte para internacionalización para otros mods
(lo cual Minetest carece actualmente).
## Cómo usar
### Para usuarios finales
Para usar éste mod, simplemente [instálalo](http://wiki.minetest.net/Installing_Mods)
y habilítalo en la interfaz.
Éste mod intenta detectar el idioma del usuario, pero ya que no existe una solución
portable para hacerlo, éste intenta varias alternativas, y utiliza la primera
encontrada:
* Opción `language` en `minetest.conf`.
* Si ésta no está definida, usa la variable de entorno `LANG` (ésta está
siempre definida en SOs como Unix).
* Si todo falla, usa `en` (lo cual básicamente significa textos sin traducir).
En todo caso, el resultado final debe ser el In any case, the end result should be the
[Código de Idioma ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
del idioma deseado. Tenga en cuenta tambien que (de momento) solo los dos primeros
caracteres son usados, así que por ejemplo, las opciones `de_DE.UTF-8`, `de_DE`,
y `de` son iguales.
Algunos códigos comúnes: `es` para Español, `pt` para Portugués, `fr` para Francés,
`it` para Italiano, `de` para Aleman.
### Para desarrolladores
Para habilitar funcionalidad en tu mod, copia el siguiente fragmento de código y pégalo
al comienzo de tus archivos fuente:
```lua
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
-- Si no requieres patrones de reemplazo (@1, @2, etc) usa ésto:
S = function(s) return s end
-- Si requieres patrones de reemplazo, pero no escapes, usa ésto:
S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
-- Usa ésto si necesitas funcionalidad completa:
S = function(s,a,...)if a==nil then return s end a={a,...}return s:gsub("(@?)@(%(?)(%d+)(%)?)",function(e,o,n,c)if e==""then return a[tonumber(n)]..(o==""and c or"")else return"@"..o..n..c end end) end
end
```
Tambien necesitarás depender opcionalmente de intllib. Para hacerlo, añade `intllib?`
a tu archivo `depends.txt`. Ten en cuenta tambien que si intllib no está instalado,
la función `S` es definida para regresar la cadena sin cambios. Ésto se hace para
evitar la necesidad de llenar tu código con montones de `if`s (o similar) para verificar
que la biblioteca está instalada.
Luego, para cada cadena de texto a traducir en tu código, usa la función `S`
(definida en el fragmento de arriba) para regresar la cadena traducida. Por ejemplo:
```lua
minetest.register_node("mimod:minodo", {
-- Cadena simple:
description = S("My Fabulous Node"),
-- Cadena con patrones de reemplazo:
description = S("@1 Car", "Blue"),
-- ...
})
```
Nota: Las cadenas en el código fuente por lo general deben estar en ingles ya que
es el idioma que más se habla. Es perfectamente posible especificar las cadenas
fuente en español y proveer una traducción al ingles, pero no se recomienda.
Luego, crea un directorio llamado `locale` dentro del directorio de tu mod, y crea
un archivo "plantilla" (llamado `template.txt` por lo general) con todas las cadenas
a traducir (ver *Formato de archivo de traducciones* más abajo). Los traductores
traducirán las cadenas en éste archivo para agregar idiomas a tu mod.
### Para traductores
Para traducir un mod que tenga soporte para intllib al idioma deseado, copia el
archivo `locale/template.txt` a `locale/IDIOMA.txt` (donde `IDIOMA` es el
[Código de Idioma ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
de tu idioma (`es` para español).
Abre el archivo en tu editor favorito, y traduce cada línea colocando el texto
traducido luego del signo de igualdad.
Ver *Formato de archivo de traducciones* más abajo.
## Formato de archivo de traducciones
He aquí un ejemplo de archivo de idioma para el español (`es.txt`):
```cfg
# Un comentario.
# Otro comentario.
Ésta línea es ignorada porque no tiene un signo de igualdad.
Hello, World! = Hola, Mundo!
String with\nnewlines = Cadena con\nsaltos de linea
String with an \= equals sign = Cadena con un signo de \= igualdad
```
Archivos de idioma (o traducción) son archivos de texto sin formato que consisten de
líneas con el formato `texto fuente = texto traducido`. El archivo debe ubicarse en el
subdirectorio `locale` del mod, y su nombre debe ser las dos letras del
[Código de Idioma ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
del lenguaje al cual se desea traducir.
Los archivos deben usar la codificación UTF-8.
Las líneas que comienzan en el símbolo numeral (`#`) son comentarios y son ignoradas
por el lector. Tenga en cuenta que los comentarios terminan al final de la línea;
no hay soporte para comentarios multilínea. Las líneas que no contengan un signo
de igualdad (`=`) tambien son ignoradas.
## Palabras finales
Gracias por leer hasta aquí.
Si tienes algún comentario/sugerencia, por favor publica en el
[tema en los foros](https://forum.minetest.net/viewtopic.php?id=4929). Para
reportar errores, usa el [rastreador](https://github.com/minetest-mods/intllib/issues/new)
en Github.
¡Que se hagan las traducciones! :P
\--
Suyo,
Kaeza

View File

@ -23,10 +23,10 @@ A fim de habilitá-lo para o seu mod, copie o seguinte trecho de código e cole
S = function(s,a,...)if a==nil then return s end a={a,...}return s:gsub("(@?)@(%(?)(%d+)(%)?)",function(e,o,n,c)if e==""then return a[tonumber(n)]..(o==""and c or"")else return"@"..o..n..c end end) end
end
Você também vai precisar depender opcionalmente do mod intllib, adicionando "intllib?"
em uma linha vazia de seu depends.txt. Observe também que se intllib não estiver
Você também vai precisar depender opcionalmente do mod intllib, adicionando "intllib?"
em uma linha vazia de seu depends.txt. Observe também que se intllib não estiver
instalado, a função S() é definido para retornar a string inalterada. Isto é feito
para que você não tenha que regar toneladas de 'if's (ou de estruturas semelhantes)
para que você não tenha que regar toneladas de 'if's (ou de estruturas semelhantes)
para verificar se a lib está realmente instalada.
Em seguida, para cada string "traduzível" em suas fontes, use a função S()
@ -42,7 +42,7 @@ no qual você deve colocar os arquivos nomeados com duas letras ( de acordo
com a ISO para códigos de idiomas) para os idiomas que seu mod vai suportar.
Aqui vai um exemplo de arquivo para idioma espanhol ('es.txt'):
# As linhas que começam com um sinal de libra '#' são comentários e
# As linhas que começam com um sinal de libra '#' são comentários e
# efetivamente ignorados pelo carregamento.
# Note-se que comentários duram apenas até o fim da linha;
# Não há nenhum suporte para comentários de várias linhas.
@ -50,16 +50,16 @@ Aqui vai um exemplo de arquivo para idioma espanhol ('es.txt'):
String com\npulo de linha = Cadena con\nsaltos de linea
String com um sinal de \= igualdade = Cadena con un signo de \= igualdad
Como atualmente não existe nenhuma maneira portátil para detectar o idioma,
Como atualmente não existe nenhuma maneira portátil para detectar o idioma,
esta biblioteca tenta várias alternativas, e usa o primeiro encontrado:
- Valor de 'language' definido em 'minetest.conf'
- Variavel de ambiente 'LANG' (normalmente definida em Unix-like SO's).
- Padrão "en".
Note que, em qualquer caso, apenas até os dois primeiros caracteres são usados
para cada idioma, por exemplo, as definições de "pt_BR.UTF-8", "pt_BR", e "pt"
para cada idioma, por exemplo, as definições de "pt_BR.UTF-8", "pt_BR", e "pt"
são todos iguais.
Os usuários do Windows não têm a variavel de ambiente 'LANG' por padrão.
Os usuários do Windows não têm a variavel de ambiente 'LANG' por padrão.
Para adicioná-lo, faça o seguinte:
- Clique em Iniciar > Configurações > Painel de Controle.
- Iniciar o aplicativo "System".
@ -68,13 +68,13 @@ Para adicioná-lo, faça o seguinte:
- Clique em "Novo".
- Tipo "LANG" (sem aspas) com o nome e o código de linguagem como valor.
- Clique em OK até que todas as caixas de diálogo estão fechadas.
Como alternativa para todas as plataformas, se você não quiser modificar as
configurações do sistema, você pode adicionar a seguinte linha ao seu
Como alternativa para todas as plataformas, se você não quiser modificar as
configurações do sistema, você pode adicionar a seguinte linha ao seu
arquivo 'minetest.conf':
language = <código de idioma>
Note também que existem alguns problemas com o uso acentos gráficos e, em geral
caracteres não-latinos em strings. Até que uma correção seja encontrada,
caracteres não-latinos em strings. Até que uma correção seja encontrada,
por favor, limite-se a usar apenas caracteres da US-ASCII.

174
README.md
View File

@ -1,83 +1,143 @@
Internationalization Lib for Minetest
By Diego Martínez (a.k.a. "Kaeza").
# Internationalization Lib for Minetest
By Diego Martínez (kaeza).
Released as WTFPL.
This mod is an attempt at providing internationalization support for mods
(something Minetest currently lacks).
How do I use it?
## How to use
### For end users
To use this mod, just [install it](http://wiki.minetest.net/Installing_Mods)
and enable it in the GUI.
The mod tries to detect the user's language, but since there's currently no
portable way to do this, it tries several alternatives, and uses the first one
found:
* `language` setting in `minetest.conf`.
* If that's not set, it uses the `LANG` environment variable (this is
always set on Unix-like OSes).
* If all else fails, uses `en` (which basically means untranslated strings).
In any case, the end result should be the
[ISO 639-1 Language Code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
of the desired language. Also note that (currently) only up to the first two
characters are used, so for example, the settings `de_DE.UTF-8`, `de_DE`,
and `de` are all equal.
Some common codes are `es` for Spanish, `pt` for Portuguese, `fr` for French,
`it` for Italian, `de` for German.
### For mod developers
In order to enable it for your mod, copy the following code snippet and paste
it at the beginning of your source file(s):
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
-- If you don't use insertions (@1, @2, etc) you can use this:
S = function(s) return s end
```lua
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
-- If you don't use insertions (@1, @2, etc) you can use this:
S = function(s) return s end
-- If you use insertions, but not insertion escapes this will work:
S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
-- If you use insertions, but not insertion escapes this will work:
S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
-- Use this if you require full functionality
S = function(s,a,...)if a==nil then return s end a={a,...}return s:gsub("(@?)@(%(?)(%d+)(%)?)",function(e,o,n,c)if e==""then return a[tonumber(n)]..(o==""and c or"")else return"@"..o..n..c end end) end
end
-- Use this if you require full functionality
S = function(s,a,...)if a==nil then return s end a={a,...}return s:gsub("(@?)@(%(?)(%d+)(%)?)",function(e,o,n,c)if e==""then return a[tonumber(n)]..(o==""and c or"")else return"@"..o..n..c end end) end
end
```
You will also need to optionally depend on intllib, to do so add "intllib?" to
a empty line in your depends.txt. Also note that if intllib is not installed,
the S() function is defined so it returns the string unchanged. This is done
so you don't have to sprinkle tons of 'if's (or similar constructs) to check
You will also need to optionally depend on intllib, to do so add `intllib?` to
an empty line in your `depends.txt`. Also note that if intllib is not installed,
the `S` function is defined so it returns the string unchanged. This is done
so you don't have to sprinkle tons of `if`s (or similar constructs) to check
if the lib is actually installed.
Next, for each "translatable" string in your sources, use the S() function
Next, for each translatable string in your sources, use the `S` function
(defined in the snippet) to return the translated string. For example:
minetest.register_node("mymod:mynode", {
description = S("My Fabulous Node"),
<...>
})
```lua
minetest.register_node("mymod:mynode", {
-- Simple string:
description = S("My Fabulous Node"),
-- String with insertions:
description = S("@1 Car", "Blue"),
-- ...
})
```
Then, you create a `locale' directory inside your mod directory, with files
named after the two-letter ISO Language Code of the languages you want to
support. Here's an example for a Spanish locale file (`es.txt'):
Then, you create a `locale` directory inside your mod directory, and create
a "template" file (by convention, named `template.txt`) with all the
translatable strings (see *Locale file format* below). Translators will
translate the strings in this file to add languages to your mod.
# Lines beginning with a pound sign are comments and are effectively ignored
# by the reader. Note that comments only span until the end of the line;
# there's no support for multiline comments.
Hello, World! = Hola, Mundo!
String with\nnewlines = Cadena con\nsaltos de linea
String with an \= equals sign = Cadena con un signo de \= igualdad
### For translators
Since there's currently no portable way to detect the language, this library
tries several alternatives, and uses the first one found:
- `language' setting in `minetest.conf'
- `LANG' environment variable (this is always set on Unix-like OSes).
- Default of "en".
Note that in any case only up to the first two characters are used, so for
example, the settings "de_DE.UTF-8", "de_DE", and "de" are all equal.
Windows users have no `LANG' environment variable by default. To add it, do
the following:
- Click Start->Settings->Control Panel.
- Start the "System" applet.
- Click on the "Advanced" tab.
- Click on the "Environment variables" button
- Click "New".
- Type "LANG" (without quotes) as name and the language code as value.
- Click OK until all dialogs are closed.
Alternatively for all platforms, if you don't want to modify system settings,
you may add the following line to your `minetest.conf' file:
language = <language code>
To translate an intllib-supporting mod to your desired language, copy the
`locale/template.txt` file to `locale/LANGUAGE.txt` (where `LANGUAGE` is the
[ISO 639-1 Language Code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
of your language.
Also note that there are some problems with using accented, and in general
non-latin characters in strings. Until a fix is found, please limit yourself
to using only US-ASCII characters.
Open up the new file in your favorite editor, and translate each line putting
the translated text after the equals sign.
See *Locale file format* below for more information about the file format.
## Locale file format
Here's an example for a Spanish locale file (`es.txt`):
```cfg
# A comment.
# Another comment.
This line is ignored since it has no equals sign.
Hello, World! = Hola, Mundo!
String with\nnewlines = Cadena con\nsaltos de linea
String with an \= equals sign = Cadena con un signo de \= igualdad
```
Locale (or translation) files are plain text files consisting of lines of the
form `source text = translated text`. The file must reside in the mod's `locale`
subdirectory, and must be named after the two-letter
[ISO 639-1 Language Code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
of the language you want to support.
The translation files should use the UTF-8 encoding.
Lines beginning with a pound sign are comments and are effectively ignored
by the reader. Note that comments only span until the end of the line;
there's no support for multiline comments. Lines without an equals sign are
also ignored.
Characters that are considered "special" can be "escaped" so they are taken
literally. There are also several escape sequences that can be used:
* Any of `#`, `=` can be escaped to take them literally. The `\#`
sequence is useful if your source text begins with `#`.
* The common escape sequences `\n` and `\t`, meaning newline and
horizontal tab respectively.
* The special `\s` escape sequence represents the space character. It
is mainly useful to add leading or trailing spaces to source or
translated texts, as these spaces would be removed otherwise.
## Final words
Thanks for reading up to this point.
Should you have any comments/suggestions, please post them in the forum topic.
Should you have any comments/suggestions, please post them in the
[forum topic](https://forum.minetest.net/viewtopic.php?id=4929). For bug
reports, use the [bug tracker](https://github.com/minetest-mods/intllib/issues/new)
on Github.
Let there be translated texts! :P
--
\--
Yours Truly,
Kaeza