-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This works completely for DT-provided lua scripts translation of user scripts need a proper documentation on how to create and handle po and mo file. Future work in the user manual
- Loading branch information
Jérémy Rosen
committed
Jul 31, 2015
1 parent
fb15ab6
commit 7d26924
Showing
6 changed files
with
335 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
This file is part of darktable, | ||
copyright (c) 2015 Jeremy Rosen | ||
darktable 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. | ||
darktable 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 darktable. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "lua/lua.h" | ||
#include "libintl.h" | ||
// function used by the lua interpreter to load darktable | ||
|
||
static int lua_gettext(lua_State*L) | ||
{ | ||
const char* msgid = luaL_checkstring(L,1); | ||
lua_pushstring(L,gettext(msgid)); | ||
return 1; | ||
} | ||
|
||
static int lua_dgettext(lua_State*L) | ||
{ | ||
const char* domainname = luaL_checkstring(L,1); | ||
const char* msgid = luaL_checkstring(L,2); | ||
lua_pushstring(L,dgettext(domainname,msgid)); | ||
return 1; | ||
} | ||
|
||
static int lua_ngettext(lua_State*L) | ||
{ | ||
const char* msgid = luaL_checkstring(L,1); | ||
const char* msgid_plural = luaL_checkstring(L,2); | ||
int n = luaL_checkint(L,3); | ||
lua_pushstring(L,ngettext(msgid,msgid_plural,n)); | ||
return 1; | ||
} | ||
|
||
static int lua_dngettext(lua_State*L) | ||
{ | ||
const char* domainname = luaL_checkstring(L,1); | ||
const char* msgid = luaL_checkstring(L,2); | ||
const char* msgid_plural = luaL_checkstring(L,3); | ||
int n = luaL_checkint(L,4); | ||
lua_pushstring(L,dngettext(domainname,msgid,msgid_plural,n)); | ||
return 1; | ||
} | ||
|
||
static int lua_bindtextdomain(lua_State*L) | ||
{ | ||
const char* domainname = luaL_checkstring(L,1); | ||
const char* dirname = luaL_checkstring(L,2); | ||
bindtextdomain(domainname,dirname); | ||
return 0; | ||
} | ||
|
||
|
||
int dt_lua_init_gettext(lua_State *L) | ||
{ | ||
|
||
dt_lua_push_darktable_lib(L); | ||
dt_lua_goto_subtable(L,"gettext"); | ||
|
||
lua_pushcfunction(L,lua_gettext); | ||
lua_setfield(L,-2,"gettext"); | ||
lua_pushcfunction(L,lua_dgettext); | ||
lua_setfield(L,-2,"dgettext"); | ||
//lua_pushcfunction(L,lua_dcgettext); | ||
//lua_setfield(L,-2,"dcgettext"); | ||
lua_pushcfunction(L,lua_ngettext); | ||
lua_setfield(L,-2,"ngettext"); | ||
lua_pushcfunction(L,lua_dngettext); | ||
lua_setfield(L,-2,"dngettext"); | ||
//lua_pushcfunction(L,lua_dcngettext); | ||
//lua_setfield(L,-2,"dcngettext"); | ||
lua_pushcfunction(L,lua_bindtextdomain); | ||
lua_setfield(L,-2,"bindtextdomain"); | ||
|
||
lua_pop(L,1); | ||
return 0; | ||
} | ||
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh | ||
// vim: shiftwidth=2 expandtab tabstop=2 cindent | ||
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-space on; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
This file is part of darktable, | ||
copyright (c) 2015 Jeremy Rosen | ||
darktable 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. | ||
darktable 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 darktable. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef DT_LUA_GETTEXT_H | ||
#define DT_LUA_GETTEXT_H | ||
|
||
int dt_lua_init_gettext(lua_State *L); | ||
|
||
#endif | ||
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh | ||
// vim: shiftwidth=2 expandtab tabstop=2 cindent | ||
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-space on; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters