gettextExample.lua with po and mo files
This commit is contained in:
BIN
contrib/de_DE/LC_MESSAGES/gettextExample.mo
Normal file
BIN
contrib/de_DE/LC_MESSAGES/gettextExample.mo
Normal file
Binary file not shown.
20
contrib/de_DE/LC_MESSAGES/gettextExample.po
Normal file
20
contrib/de_DE/LC_MESSAGES/gettextExample.po
Normal file
@@ -0,0 +1,20 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Lua gettextTest\n"
|
||||
"POT-Creation-Date: 2016-01-07 20:33+0100\n"
|
||||
"PO-Revision-Date: 2016-01-07 21:32+0100\n"
|
||||
"Last-Translator: Tobias Jakobs <tobias.jakobs@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: de\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.4\n"
|
||||
"X-Poedit-Basepath: .\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-KeywordsList: gettext;dgettext:2;dcgettext:2;ngettext:1,2;dngettext:2,3\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: gettextExample.lua:36
|
||||
msgid "Hello World!"
|
||||
msgstr "Hallo Welt!"
|
||||
51
contrib/gettextExample.lua
Normal file
51
contrib/gettextExample.lua
Normal file
@@ -0,0 +1,51 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright 2016 by Tobias Jakobs.
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
]]
|
||||
--[[
|
||||
darktable script to show how translations works
|
||||
|
||||
To create a .mo file run:
|
||||
msgfmt -v gettextExample.po -o gettextExample.mo
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file (Add 'require "gettextExample"' to luarc.)
|
||||
* copy the script to: .config/darktable/lua/
|
||||
* copy the gettextExample.mo to .config/darktable/lua/de_DE/LC_MESSAGES
|
||||
|
||||
You need to start darktable with the Lua debug option: darktable -d lua
|
||||
$LANG must set to: de_DE
|
||||
|
||||
The script run on darktable startup and should output this three lines:
|
||||
|
||||
LUA ERROR Hello World!
|
||||
LUA ERROR Bild
|
||||
LUA ERROR Hallo Welt!
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{3,0,0})
|
||||
|
||||
-- Not translated Text
|
||||
dt.print_error("Hello World!")
|
||||
|
||||
-- Translate a string using the darktable textdomain
|
||||
dt.print_error(dt.gettext.gettext("image"))
|
||||
|
||||
-- Tell gettext where to find the .mo file translating messages for a particular domain
|
||||
dt.gettext.bindtextdomain("gettextExample",".config/darktable/lua/")
|
||||
-- Translate a string using the specified textdomain
|
||||
dt.print_error(dt.gettext.dgettext("gettextExample", 'Hello World!'))
|
||||
Reference in New Issue
Block a user