1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2013 - Scilab Enterprises - Antoine ELIAS
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution. The terms
7 // are also available at
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 function tbx_build_localization(tbx_name, tbx_path)
14 if and(rhs <> [1 2]) then
15 error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"tbx_build_localization",1,2));
18 if type(tbx_name) <> 10 then
19 error(tbx_name(gettext("%s: Wrong type for input argument #%d: A string array expected.\n"),"tbx_build_localization",1));
25 if type(tbx_path) <> 10 then
26 error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"tbx_build_localization",2));
29 if size(tbx_path,"*") <> 1 then
30 error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"),"tbx_build_localization",2));
33 if ~isdir(tbx_path) then
34 error(msprintf(gettext("%s: The directory ''%s'' doesn''t exist or is not read accessible.\n"),"tbx_build_localization", tbx_path));
39 localePath = tbx_path + "locales/";
41 if isdir(localePath) == %f then
42 error(msprintf(gettext("%s: The directory ''%s'' doesn''t exist or is not read accessible.\n"),"tbx_build_localization",localePath));
45 //find list of .po files
46 poFiles = gsort(findfiles(localePath, "*.po"), "lr", "i");
48 if getos() == "Windows" then
49 cmd = SCI + filesep() + "tools/gettext/msgfmt";
54 mprintf(gettext("Generating localization\n"));
55 for i=1:size(poFiles, "*")
56 //generate moFile name and path
57 lang = fileparts(poFiles(i), "fname");
58 printf("-- Building for ""%s"" --\n", lang);
59 moFile = localePath + lang + "/LC_MESSAGES/";
60 mkdir(moFile); //to be sure path exists
61 poFile = moFile + tbx_name + ".po";
62 moFile = moFile + tbx_name + ".mo";
65 //check mo file is newest po, don't need to generate it
66 if newest(poFiles(i), moFile) == 1 then
67 copyfile(localePath + poFiles(i), poFile);
68 cmd1 = cmd + " -o " + moFile + " " + poFile;