diff --git a/mods/intllib/README-es_UY.md b/mods/intllib/README-es_UY.md deleted file mode 100644 index fdaafc3..0000000 --- a/mods/intllib/README-es_UY.md +++ /dev/null @@ -1,136 +0,0 @@ - -# Biblioteca de Internacionalización para Luanti - -Por Diego Martínez (kaeza). -Lanzada bajo MIT License. - -Éste mod es un intento de proveer soporte para internacionalización para otros mods -(lo cual Luanti carece actualmente). - -## Cómo usar - -### Para usuarios finales - -Para usar éste mod, simplemente [instálalo](http://wiki.luanti.org/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.luanti.org/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 diff --git a/mods/intllib/README-pt_BR.md b/mods/intllib/README-pt_BR.md deleted file mode 100644 index dca59a0..0000000 --- a/mods/intllib/README-pt_BR.md +++ /dev/null @@ -1,142 +0,0 @@ -# Lib de Internacionalização para Luanti - -Por Diego Martínez (kaeza). -Lançado como MIT License. - -Este mod é uma tentativa de fornecer suporte de internacionalização para mods -(algo que Luanti atualmente carece). - -## Como usar - -### Para usuários finais - -Para usar este mod, basta [instalá-lo] (http://wiki.luanti.org/Installing_Mods) -e habilita-lo na GUI. - -O modificador tenta detectar o idioma do usuário, mas já que não há atualmente -nenhuma maneira portátil para fazer isso, ele tenta várias alternativas, e usa -o primeiro encontrado: - - * `language` definido em `minetest.conf`. - * Se isso não for definido, ele usa a variável de ambiente `LANG` (isso - é sempre definido em SO's Unix-like). - * Se todos falharem, usa `en` (que basicamente significa string não traduzidas). - -Em todo caso, o resultado final deve ser um -[Código de Idioma ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) -do idioma desejado. Observe também que (atualmente) somente até os dois primeiros -caracteres são usados, assim, por exemplo, os códigos `pt_BR.UTF-8`, `pt_BR`, e `pt` -são todos iguais. - -Alguns códigos comuns são `es` para o espanhol, `pt` para Português, `fr` para o -francês, `It` para o italiano, `de` Alemão. - -### Para desenvolvedores de mods - -A fim de habilitá-lo para o seu mod, copie o seguinte trecho de código e cole no -início de seu(s) arquivo(s) fonte(s): - -```lua --- Clichê para apoiar cadeias localizadas se mod intllib está instalado. -local S -if minetest.get_modpath("intllib") then - S = intllib.Getter() -else - -- Se você não usar inserções (@1, @2, etc) você pode usar este: - S = function(s) return s end - - -- Se você usar inserções, mas não usar escapes de inserção (\=, \n, etc) isso vai funcionar: - S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end - - -- Use isso se você precisar de funcionalidade total: - 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 -instalado, a função S() é definido para retornar a string inalterada. Isto é feito -para que você não tenha que usar dezenas 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() -(definida no trecho anterior) para retornar uma string traduzida. Por exemplo: - -```lua -minetest.register_node("mymod:meunode", { - -- String simples - description = S("Meu Node Fabuloso"), - -- String com inserção de variáveis - description = S("@1 Car", "Blue"), - -- ... -}) -``` - -Em seguida, crie um diretório chamado `locale` dentro do diretório do seu mod, -e crie um arquivo modelo (por convenção, nomeado `template.txt`) contendo todas -as strings traduzíveis (veja *Formato de arquivo Locale* abaixo). Tradutores -irão traduzir as strings neste arquivo para adicionar idiomas ao seu mod. - -### Para tradutores - -Para traduzir um mod intllib-apoiado para o idioma desejado, copie o -arquivo `locale/template.txt` para`locale/IDIOMA.txt` (onde `IDIOMA` é o -[Código de Idioma ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) -do idioma desejado. - -Abra o novo arquivo no seu editor favorito, e traduza cada linha colocando -o texto traduzido após o sinal de igual. - -Veja *Formato de arquivo Locale* abaixo para mais informações sobre o formato de arquivo. - -## Formato de arquivo Locale - -Aqui está um exemplo de um arquivo locale Português (`pt.txt`): - -```cfg -# Um comentário. -# Outro Comentário. -Esta linha é ignorada, uma vez que não tem sinal de igual. -Hello, World! = Ola, Mundo! -String with\nnewlines = String com\nsaltos de linha -String with an \= equals sign = String com sinal de \= igual -``` - -Locale (ou tradução) são arquivos de texto simples que consistem em linhas da -forma `texto de origem = texto traduzido`. O arquivo deve residir no subdiretório -`locale` do mod, e deve ser nomeado com as duas letras do -[Código de Idioma ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) -do idioma que deseja apoiar. - -Os arquivos de tradução devem usar a codificação UTF-8. - -As linhas que começam com um sinal de libra (#) são comentários e são efetivamente -ignorados pelo interpretador. Note que comentários duram apenas até o fim da linha; -não há suporte para comentários de várias linhas. Linhas sem um sinal de igual são -ignoradas também. - -Caracteres considerados "especiais" podem ser "escapados" para que sejam -interpretados corretamente. Existem várias sequências de escape que podem ser usadas: - - * Qualquer `#` ou `=` pode ser escapado para ser interpretado corretamente. - A sequência `\#` é útil se o texto de origem começa com `#`. - * Sequências de escape comuns são `\n` e` \t`, ou seja, de nova linha e - guia horizontal, respectivamente. - * A sequência de escape especial `\s` representa o caractere de espaço. isto - pode ser útil principalmente para adicionar espaços antes ou depois de fonte ou - textos traduzida, uma vez que estes espaços seriam removidos de outro modo. - -## Palavras Finais - -Obrigado por ler até este ponto. -Se você tiver quaisquer comentários/sugestões, por favor poste no -[Tópico do fórum](https://forum.luanti.org/viewtopic.php?id=4929) (em inglês). Para -relatórios de bugs, use o [Rastreador de bugs](https://github.com/minetest-mods/intllib/issues/new) -no Github. - -Haja textos traduzidos! :P - -\-- - -Atenciosamente, -Kaeza diff --git a/mods/intllib/README.md b/mods/intllib/README.md deleted file mode 100644 index d1c6a19..0000000 --- a/mods/intllib/README.md +++ /dev/null @@ -1,143 +0,0 @@ - -# Internationalization Lib for Luanti - -By Diego Martínez (kaeza). -Released under MIT License. - -This mod is an attempt at providing internationalization support for mods -(something Luanti currently lacks). - -## How to use - -### For end users - -To use this mod, just [install it](http://wiki.luanti.org/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): - -```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 - - -- 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 -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 -(defined in the snippet) to return the translated string. For example: - -```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, 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. - -### For translators - -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. - -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](https://forum.luanti.org/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 diff --git a/mods/intllib/init.lua b/mods/intllib/init.lua deleted file mode 100644 index c44a532..0000000 --- a/mods/intllib/init.lua +++ /dev/null @@ -1,90 +0,0 @@ - --- Old multi-load method compatibility -if rawget(_G, "intllib") then return end - -intllib = { - getters = {}, - strings = {}, -} - - -local MP = minetest.get_modpath("intllib") - -dofile(MP.."/lib.lua") - - -local LANG = minetest.settings:get("language") -if not (LANG and (LANG ~= "")) then LANG = os.getenv("LANG") end -if not (LANG and (LANG ~= "")) then LANG = "en" end - - -local INS_CHAR = intllib.INSERTION_CHAR -local insertion_pattern = "("..INS_CHAR.."?)"..INS_CHAR.."(%(?)(%d+)(%)?)" - -local function make_getter(msgstrs) - return function(s, ...) - local str - if msgstrs then - str = msgstrs[s] - end - if not str or str == "" then - str = s - end - if select("#", ...) == 0 then - return str - end - local args = {...} - str = str:gsub(insertion_pattern, function(escape, open, num, close) - if escape == "" then - local replacement = tostring(args[tonumber(num)]) - if open == "" then - replacement = replacement..close - end - return replacement - else - return INS_CHAR..open..num..close - end - end) - return str - end -end - - -function intllib.Getter(modname) - modname = modname or minetest.get_current_modname() - if not intllib.getters[modname] then - local msgstr = intllib.get_strings(modname) - intllib.getters[modname] = make_getter(msgstr) - end - return intllib.getters[modname] -end - - -local function get_locales(code) - local ll, cc = code:match("^(..)_(..)") - if ll then - return { ll.."_"..cc, ll, ll~="en" and "en" or nil } - else - return { code, code~="en" and "en" or nil } - end -end - - -function intllib.get_strings(modname, langcode) - langcode = langcode or LANG - modname = modname or minetest.get_current_modname() - local msgstr = intllib.strings[modname] - if not msgstr then - local modpath = minetest.get_modpath(modname) - msgstr = { } - for _, l in ipairs(get_locales(langcode)) do - local t = intllib.load_strings(modpath.."/locale/"..l..".txt") or { } - for k, v in pairs(t) do - msgstr[k] = msgstr[k] or v - end - end - intllib.strings[modname] = msgstr - end - return msgstr -end - diff --git a/mods/intllib/intllib.lua b/mods/intllib/intllib.lua deleted file mode 100644 index adb0f88..0000000 --- a/mods/intllib/intllib.lua +++ /dev/null @@ -1,3 +0,0 @@ --- Support for the old multi-load method -dofile(minetest.get_modpath("intllib").."/init.lua") - diff --git a/mods/intllib/lib.lua b/mods/intllib/lib.lua deleted file mode 100644 index 7e8e066..0000000 --- a/mods/intllib/lib.lua +++ /dev/null @@ -1,67 +0,0 @@ - -intllib = intllib or {} - -local INS_CHAR = "@" -intllib.INSERTION_CHAR = INS_CHAR - -local escapes = { - ["\\"] = "\\", - ["n"] = "\n", - ["s"] = " ", - ["t"] = "\t", - ["r"] = "\r", - ["f"] = "\f", - [INS_CHAR] = INS_CHAR..INS_CHAR, -} - -local function unescape(str) - local parts = {} - local n = 1 - local function add(s) - parts[n] = s - n = n + 1 - end - - local start = 1 - while true do - local pos = str:find("\\", start, true) - if pos then - add(str:sub(start, pos - 1)) - else - add(str:sub(start)) - break - end - local c = str:sub(pos + 1, pos + 1) - add(escapes[c] or c) - start = pos + 2 - end - return table.concat(parts) -end - -local function find_eq(s) - for slashes, pos in s:gmatch("([\\]*)=()") do - if (slashes:len() % 2) == 0 then - return pos - 1 - end - end -end - -function intllib.load_strings(filename) - local file, err = io.open(filename, "r") - if not file then - return nil - end - local strings = {} - for line in file:lines() do - line = line:trim() - if line ~= "" and line:sub(1, 1) ~= "#" then - local pos = find_eq(line) - if pos then - local msgid = unescape(line:sub(1, pos - 1):trim()) - strings[msgid] = unescape(line:sub(pos + 1):trim()) - end - end - end - file:close() - return strings -end diff --git a/mods/intllib/mod.conf b/mods/intllib/mod.conf deleted file mode 100644 index fa00539..0000000 --- a/mods/intllib/mod.conf +++ /dev/null @@ -1,2 +0,0 @@ -name = intllib -description = Internationalization library. This mod provides a way to internationalize/localize mods to other languages in an easy way. See the README file for details. diff --git a/mods/intllib/tools/findtext.lua b/mods/intllib/tools/findtext.lua deleted file mode 100755 index b6360cb..0000000 --- a/mods/intllib/tools/findtext.lua +++ /dev/null @@ -1,142 +0,0 @@ -#! /usr/bin/env lua - -local me = arg[0]:gsub(".*[/\\](.*)$", "%1") - -local function err(fmt, ...) - io.stderr:write(("%s: %s\n"):format(me, fmt:format(...))) - os.exit(1) -end - -local output -local inputs = { } -local lang -local author - -local i = 1 - -local function usage() - print([[ -Usage: ]]..me..[[ [OPTIONS] FILE... - -Extract translatable strings from the given FILE(s). - -Available options: - -h,--help Show this help screen and exit. - -o,--output X Set output file (default: stdout). - -a,--author X Set author. - -l,--lang X Set language name. -]]) - os.exit(0) -end - -while i <= #arg do - local a = arg[i] - if (a == "-h") or (a == "--help") then - usage() - elseif (a == "-o") or (a == "--output") then - i = i + 1 - if i > #arg then - err("missing required argument to `%s'", a) - end - output = arg[i] - elseif (a == "-a") or (a == "--author") then - i = i + 1 - if i > #arg then - err("missing required argument to `%s'", a) - end - author = arg[i] - elseif (a == "-l") or (a == "--lang") then - i = i + 1 - if i > #arg then - err("missing required argument to `%s'", a) - end - lang = arg[i] - elseif a:sub(1, 1) ~= "-" then - table.insert(inputs, a) - else - err("unrecognized option `%s'", a) - end - i = i + 1 -end - -if #inputs == 0 then - err("no input files") -end - -local outfile = io.stdout - -local function printf(fmt, ...) - outfile:write(fmt:format(...)) -end - -if output then - local e - outfile, e = io.open(output, "w") - if not outfile then - err("error opening file for writing: %s", e) - end -end - -if author or lang then - outfile:write("\n") -end - -if lang then - printf("# Language: %s\n", lang) -end - -if author then - printf("# Author: %s\n", author) -end - -if author or lang then - outfile:write("\n") -end - -local escapes = { - ["\n"] = "\\n", - ["="] = "\\=", - ["\\"] = "\\\\", -} - -local function escape(s) - return s:gsub("[\\\n=]", escapes) -end - -local messages = { } - -for _, file in ipairs(inputs) do - local infile, e = io.open(file, "r") - if infile then - for line in infile:lines() do - for s in line:gmatch('S%("([^"]*)"') do - table.insert(messages, s) - end - end - infile:close() - else - io.stderr:write(("%s: WARNING: error opening file: %s\n"):format(me, e)) - end -end - -table.sort(messages) - -local last_msg - -for i, msg in ipairs(messages) do - if msg ~= last_msg then - printf("%s =\n", escape(msg)) - end - last_msg = msg -end - -if output then - outfile:close() -end - ---[[ -TESTS: -S("foo") S("bar") -S("bar") -S("foo") -]] diff --git a/mods/intllib/tools/updatetext.lua b/mods/intllib/tools/updatetext.lua deleted file mode 100644 index 00f9bf6..0000000 --- a/mods/intllib/tools/updatetext.lua +++ /dev/null @@ -1,141 +0,0 @@ -#! /usr/bin/env lua - -local basedir = "" -if arg[0]:find("[/\\]") then - basedir = arg[0]:gsub("(.*[/\\]).*$", "%1"):gsub("\\", "/") -end -if basedir == "" then basedir = "./" end - --- Required by load_strings() -function string.trim(s) - return s:gsub("^%s*(.-)%s*$", "%1") -end - -dofile(basedir.."/../lib.lua") - -local me = arg[0]:gsub(".*[/\\](.*)$", "%1") - -local function err(fmt, ...) - io.stderr:write(("%s: %s\n"):format(me, fmt:format(...))) - os.exit(1) -end - -local template -local catalogs = { } - -local function usage() - print([[ -Usage: ]]..me..[[ [OPTIONS] TEMPLATE CATALOG... - -Update a catalog with new strings from a template. - -Available options: - -h,--help Show this help screen and exit. - -o,--output X Set output file (default: stdout). - -Messages in the template that are not on the catalog are added to the -catalog at the end. - -This tool also checks messages that are in the catalog but not in the -template, and reports such lines. It's up to the user to remove such -lines, if so desired. -]]) - os.exit(0) -end - -local i = 1 - -while i <= #arg do - local a = arg[i] - if (a == "-h") or (a == "--help") then - usage() - elseif (a == "-o") or (a == "--output") then - i = i + 1 - if i > #arg then - err("missing required argument to `%s'", a) - end - elseif (a == "-c") or (a == "--comment") then - old_msg_mode = "c" - elseif (a == "-d") or (a == "--delete") then - old_msg_mode = "d" - elseif a:sub(1, 1) ~= "-" then - if not template then - template = a - else - table.insert(catalogs, a) - end - else - err("unrecognized option `%s'", a) - end - i = i + 1 -end - -if not template then - err("no template specified") -elseif #catalogs == 0 then - err("no catalogs specified") -end - -local f, e = io.open(template, "r") -if not f then - err("error opening template: %s", e) -end - -local function printf(fmt, ...) - outfile:write(fmt:format(...)) -end - -local escapes = { ["\n"] = "\\n", ["="] = "\\=", ["\\"] = "\\\\", } -local function escape(s) - return s:gsub("[\\\n=]", escapes) -end - -if output then - local e - outfile, e = io.open(output, "w") - if not outfile then - err("error opening file for writing: %s", e) - end -end - -local function printf(fmt, ...) - io.stdout:write(fmt:format(...)) -end - -local template_msgs = intllib.load_strings(template) - -for _, file in ipairs(catalogs) do - print("Processing: "..file) - local catalog_msgs = intllib.load_strings(file) - local dirty_lines = { } - if catalog_msgs then - -- Add new entries from template. - for k in pairs(template_msgs) do - if not catalog_msgs[k] then - print("NEW: "..k) - table.insert(dirty_lines, escape(k).." =") - end - end - -- Check for old messages. - for k, v in pairs(catalog_msgs) do - if not template_msgs[k] then - print("OLD: "..k) - end - end - if #dirty_lines > 0 then - local outf, e = io.open(file, "a+") - if outf then - outf:write("\n") - for _, line in ipairs(dirty_lines) do - outf:write(line) - outf:write("\n") - end - outf:close() - else - io.stderr:write(("%s: WARNING: cannot write: %s\n"):format(me, e)) - end - end - else - io.stderr:write(("%s: WARNING: could not load catalog\n"):format(me)) - end -end diff --git a/mods/tutorial/init.lua b/mods/tutorial/init.lua index 19b8d2f..a1ef2a4 100644 --- a/mods/tutorial/init.lua +++ b/mods/tutorial/init.lua @@ -12,13 +12,7 @@ end -- == END OF DEBUG SETTINGS == --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial") -- Saves tutorial state into file function tutorial.save_state() @@ -1564,29 +1558,18 @@ function tutorial.go_to_end(player) end --[[ -Helper tools for sign text extracting +Helper tool for sign text extracting must be called with /lua from luacmd An ugly, quick and dirty hack. -TODO: Toss away intllib in favor of gettext as soon as possible ]] -function tutorial.convert_newlines_for_intllib(str) - local function convert(s) - return s:gsub("\n", function(slash, what) - return "\\n" - end) - end - - return convert(str) -end - function tutorial.extract_texts() local filepath = minetest.get_modpath("tutorial").."/locale/template_texts.txt" local file = io.open(filepath, "w+") if(file) then for k,v in pairs(tutorial.texts) do file:write("# Tutorial text: "..k.."\n") - file:write(tutorial.convert_newlines_for_intllib(v).."\n\n") + file:write(v.."\n\n") end else minetest.log("error", "[tutorial] An attempt to write into "..filepath.." failed.") diff --git a/mods/tutorial/mod.conf b/mods/tutorial/mod.conf index 23cba1b..8dfa01f 100644 --- a/mods/tutorial/mod.conf +++ b/mods/tutorial/mod.conf @@ -1,4 +1,3 @@ name = tutorial description = This mod provides some additional items neccessary for the tutorial. depends = tutorial_default -optional_depends = intllib diff --git a/mods/tutorial_areas/hud.lua b/mods/tutorial_areas/hud.lua index 486a01a..168e68f 100644 --- a/mods/tutorial_areas/hud.lua +++ b/mods/tutorial_areas/hud.lua @@ -1,10 +1,4 @@ --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_areas") -- Legacy support: Name of the HUD type field for 'hud_add'. local hud_type_field_name diff --git a/mods/tutorial_areas/mod.conf b/mods/tutorial_areas/mod.conf index 1a24343..90bcbc0 100644 --- a/mods/tutorial_areas/mod.conf +++ b/mods/tutorial_areas/mod.conf @@ -1,2 +1 @@ name = tutorial_areas -optional_depends = intllib diff --git a/mods/tutorial_arrow_signs/init.lua b/mods/tutorial_arrow_signs/init.lua index b5b899b..c9862c8 100644 --- a/mods/tutorial_arrow_signs/init.lua +++ b/mods/tutorial_arrow_signs/init.lua @@ -3,14 +3,8 @@ --see: http://creativecommons.org/licenses/by-sa/3.0/ --modified and simplified for Tutorial --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end - +local S = minetest.get_translator("tutorial_arrow_signs") + arrow_signs={} function arrow_signs:savetext(pos, formname, fields, sender) diff --git a/mods/tutorial_arrow_signs/mod.conf b/mods/tutorial_arrow_signs/mod.conf index 84f62fc..e3f24c8 100644 --- a/mods/tutorial_arrow_signs/mod.conf +++ b/mods/tutorial_arrow_signs/mod.conf @@ -1,3 +1,3 @@ name = tutorial_arrow_signs depends = tutorial_default -optional_depends = locks, intllib +optional_depends = locks diff --git a/mods/tutorial_castle/mod.conf b/mods/tutorial_castle/mod.conf index 3701399..2098f33 100644 --- a/mods/tutorial_castle/mod.conf +++ b/mods/tutorial_castle/mod.conf @@ -1,3 +1,2 @@ name = tutorial_castle depends = tutorial_default -optional_depends = intllib diff --git a/mods/tutorial_castle/shields_decor.lua b/mods/tutorial_castle/shields_decor.lua index ff77a7b..bd44d59 100644 --- a/mods/tutorial_castle/shields_decor.lua +++ b/mods/tutorial_castle/shields_decor.lua @@ -1,10 +1,4 @@ --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_castle") minetest.register_node("tutorial_castle:shield_2",{ description = S("mounted shield"), diff --git a/mods/tutorial_castle/town_item.lua b/mods/tutorial_castle/town_item.lua index c256ed0..ceac09c 100644 --- a/mods/tutorial_castle/town_item.lua +++ b/mods/tutorial_castle/town_item.lua @@ -1,10 +1,4 @@ --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_castle") minetest.register_node("tutorial_castle:light",{ drawtype = "glasslike", diff --git a/mods/tutorial_cottages/mod.conf b/mods/tutorial_cottages/mod.conf index 0ba1800..9c265b2 100644 --- a/mods/tutorial_cottages/mod.conf +++ b/mods/tutorial_cottages/mod.conf @@ -1,3 +1,3 @@ name = tutorial_cottages depends = tutorial_default -optional_depends = stairs, homedecor, intllib +optional_depends = stairs, homedecor diff --git a/mods/tutorial_cottages/nodes_furniture.lua b/mods/tutorial_cottages/nodes_furniture.lua index d152056..eb59cef 100644 --- a/mods/tutorial_cottages/nodes_furniture.lua +++ b/mods/tutorial_cottages/nodes_furniture.lua @@ -12,13 +12,7 @@ -- * washing place - put it over a water source and you can 'wash' yourshelf --------------------------------------------------------------------------------------- --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_cottages") -- the basic version of a bed - a sleeping mat -- to facilitate upgrade path straw mat -> sleeping mat -> bed, this uses a nodebox diff --git a/mods/tutorial_cottages/nodes_historic.lua b/mods/tutorial_cottages/nodes_historic.lua index 5471bbc..d998769 100644 --- a/mods/tutorial_cottages/nodes_historic.lua +++ b/mods/tutorial_cottages/nodes_historic.lua @@ -8,13 +8,7 @@ -- * glass pane - an improvement compared to fence posts as windows :-) --------------------------------------------------------------------------------------- --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_cottages") -- can be used to buid real stationary wagons or attached to walls as decoration minetest.register_node("tutorial_cottages:wagon_wheel", { diff --git a/mods/tutorial_cottages/nodes_roof.lua b/mods/tutorial_cottages/nodes_roof.lua index c8c665a..b5002f9 100644 --- a/mods/tutorial_cottages/nodes_roof.lua +++ b/mods/tutorial_cottages/nodes_roof.lua @@ -3,13 +3,7 @@ --------------------------------------------------------------------------------------- -- a better roof than the normal stairs; can be replaced by stairs:stair_wood --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_cottages") -- create the three basic roof parts plus receipes for them; cottages.register_roof = function( name, tiles, basic_material, homedecor_alternative, desc1, desc2, desc3 ) diff --git a/mods/tutorial_cottages/nodes_straw.lua b/mods/tutorial_cottages/nodes_straw.lua index e228367..c6651b3 100644 --- a/mods/tutorial_cottages/nodes_straw.lua +++ b/mods/tutorial_cottages/nodes_straw.lua @@ -4,13 +4,7 @@ -- * straw mat - for animals and very poor NPC; also basis for other straw things -- * straw bale - well, just a good source for building and decoration --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_cottages") -- an even simpler from of bed - usually for animals -- it is a nodebox and not wallmounted because that makes it easier to replace beds with straw mats diff --git a/mods/tutorial_creative/init.lua b/mods/tutorial_creative/init.lua index 8ea699b..cda5f23 100644 --- a/mods/tutorial_creative/init.lua +++ b/mods/tutorial_creative/init.lua @@ -1,12 +1,5 @@ --- intllib support -local S, ES -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() - ES = function( s ) return minetest.formspec_escape(S(s)) end -else - S = function ( s ) return s end - ES = function ( s ) return minetest.formspec_escape(s) end -end +local S = minetest.get_translator("tutorial_creative") +local FS = function( s ) return minetest.formspec_escape(S(s)) end creative = {} local player_inventory = {} @@ -123,13 +116,13 @@ creative.set_creative_formspec = function(player, start_i, pagenum, tab_id) button[7.25,3.2;0.8,0.9;creative_next;>] button[2.1,3.4;0.8,0.5;creative_search;?] button[2.75,3.4;0.8,0.5;creative_clear;X] - tooltip[creative_search;]]..ES("Search")..[[] - tooltip[creative_clear;]]..ES("Reset")..[[] + tooltip[creative_search;]]..FS("Search")..[[] + tooltip[creative_clear;]]..FS("Reset")..[[] listring[current_player;main] ]] .. "field[0.3,3.5;2.2,1;creative_filter;;".. filter .."]".. "listring[detached:creative_".. player_name ..";main]".. - "tabheader[0,0;creative_tabs;"..ES("Crafting")..","..ES("All")..","..ES("Nodes")..","..ES("Tools")..","..ES("Items")..";".. tostring(tab_id) ..";true;false]".. + "tabheader[0,0;creative_tabs;"..FS("Crafting")..","..FS("All")..","..FS("Nodes")..","..FS("Tools")..","..FS("Items")..";".. tostring(tab_id) ..";true;false]".. "list[detached:creative_".. player_name ..";main;0,0;8,3;".. tostring(start_i) .."]".. "table[6.05,3.35;1.15,0.5;pagenum;#FFFF00,".. tostring(pagenum) ..",#FFFFFF,/ ".. tostring(pagemax) .."]".. default.get_hotbar_bg(0,4.7).. @@ -147,7 +140,7 @@ creative.set_crafting_formspec = function(player) list[detached:creative_trash;main;0,2.75;1,1;] image[0.06,2.85;0.8,0.8;creative_trash_icon.png] image[5,1.75;1,1;gui_furnace_arrow_bg.png^[transformR270] - tabheader[0,0;creative_tabs;]]..ES("Crafting")..","..ES("All")..","..ES("Nodes")..","..ES("Tools")..","..ES("Items")..[[;1;true;false] + tabheader[0,0;creative_tabs;]]..FS("Crafting")..","..FS("All")..","..FS("Nodes")..","..FS("Tools")..","..FS("Items")..[[;1;true;false] listring[current_player;main] listring[current_player;craft] ]] .. diff --git a/mods/tutorial_creative/mod.conf b/mods/tutorial_creative/mod.conf index 5434434..4aceb08 100644 --- a/mods/tutorial_creative/mod.conf +++ b/mods/tutorial_creative/mod.conf @@ -1,3 +1,2 @@ name = tutorial_creative depends = tutorial_default -optional_depends = intllib diff --git a/mods/tutorial_darkage/mod.conf b/mods/tutorial_darkage/mod.conf index dda1ada..7823ea1 100644 --- a/mods/tutorial_darkage/mod.conf +++ b/mods/tutorial_darkage/mod.conf @@ -1,3 +1,2 @@ name = tutorial_darkage depends = tutorial_default -optional_depends = intllib diff --git a/mods/tutorial_darkage/nodes.lua b/mods/tutorial_darkage/nodes.lua index 5da262a..22de0e7 100644 --- a/mods/tutorial_darkage/nodes.lua +++ b/mods/tutorial_darkage/nodes.lua @@ -1,10 +1,4 @@ --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_darkage") minetest.register_node("tutorial_darkage:basalt_cobble", { description = S("basalt cobble"), diff --git a/mods/tutorial_default/craftitems.lua b/mods/tutorial_default/craftitems.lua index 098c71e..121fa54 100644 --- a/mods/tutorial_default/craftitems.lua +++ b/mods/tutorial_default/craftitems.lua @@ -1,14 +1,4 @@ --- intllib support -local S, F -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() - F = function( s ) - return minetest.formspec_escape(S(s)) - end -else - S = function ( s ) return s end - F = function ( s ) return minetest.formspec_escape(s) end -end +local S = minetest.get_translator("tutorial_default") minetest.register_craftitem("tutorial_default:book", { description = S("book"), diff --git a/mods/tutorial_default/init.lua b/mods/tutorial_default/init.lua index 8b95f11..58d74af 100644 --- a/mods/tutorial_default/init.lua +++ b/mods/tutorial_default/init.lua @@ -2,13 +2,7 @@ -- The API documentation in here was moved into doc/lua_api.txt --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_default") -- Definitions made by this mod that other mods can use too default = {} diff --git a/mods/tutorial_default/mod.conf b/mods/tutorial_default/mod.conf index 105763f..fd9953d 100644 --- a/mods/tutorial_default/mod.conf +++ b/mods/tutorial_default/mod.conf @@ -1,2 +1,2 @@ name = tutorial_default -optional_depends = intllib, tutorial_music +optional_depends = tutorial_music diff --git a/mods/tutorial_default/nodes.lua b/mods/tutorial_default/nodes.lua index 55374dc..d35d0ab 100644 --- a/mods/tutorial_default/nodes.lua +++ b/mods/tutorial_default/nodes.lua @@ -1,14 +1,4 @@ --- intllib support -local S, F -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() - F = function( s ) - return minetest.formspec_escape(S(s)) - end -else - S = function ( s ) return s end - F = function ( s ) return minetest.formspec_escape(s) end -end +local S = minetest.get_translator("tutorial_default") local WATER_VISC = 1 diff --git a/mods/tutorial_default/tools.lua b/mods/tutorial_default/tools.lua index b51846c..5d4ae8f 100644 --- a/mods/tutorial_default/tools.lua +++ b/mods/tutorial_default/tools.lua @@ -1,10 +1,4 @@ --- intllib support -local S, F -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_default") -- The hand minetest.register_item(":", { diff --git a/mods/tutorial_supplemental/init.lua b/mods/tutorial_supplemental/init.lua index 0fec22a..60dbd43 100644 --- a/mods/tutorial_supplemental/init.lua +++ b/mods/tutorial_supplemental/init.lua @@ -1,10 +1,4 @@ --- intllib support -local S -if (minetest.get_modpath("intllib")) then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("tutorial_supplemental") minetest.register_node("tutorial_supplemental:sticky", { description = S("sticky stone brick"), diff --git a/mods/tutorial_supplemental/mod.conf b/mods/tutorial_supplemental/mod.conf index f7e3321..a24ed6b 100644 --- a/mods/tutorial_supplemental/mod.conf +++ b/mods/tutorial_supplemental/mod.conf @@ -1,3 +1,2 @@ name = tutorial_supplemental depends = tutorial_default, tutorial_music -optional_depends = intllib