}
}
-if (!function_exists('_T')) {
- /**
- * Translate a string
- *
- * @param string $chaine The string to translate
- *
- * @return Translated string (if available) ; $chaine otherwise
- */
- function _T($chaine)
- {
- global $language, $disable_gettext, $installer;
- if ($disable_gettext === true && isset($GLOBALS['lang'])) {
- $trans = $chaine;
- if (isset($GLOBALS['lang'][$chaine])
- && $GLOBALS['lang'][$chaine] != ''
- ) {
- $trans = $GLOBALS['lang'][$chaine];
+/**
+ * Translate a string
+ *
+ * @param string $string The string to translate
+ * @param boolean $nt Indicate not translated strings; defaults to true
+ *
+ * @return Translated string (if available) ; $chaine otherwise
+ */
+function _T($string, $nt = true)
+{
+ global $language, $disable_gettext, $installer;
+ if ($disable_gettext === true && isset($GLOBALS['lang'])) {
+ if (isset($GLOBALS['lang'][$string])
+ && $GLOBALS['lang'][$string] != ''
+ ) {
+ $trans = $GLOBALS['lang'][$string];
+ } else {
+ $trans = false;
+ if (!isset($installer) || $installer !== true) {
+ $trans = getDynamicTranslation(
+ $string,
+ $language
+ );
+ }
+ if ($trans) {
+ $GLOBALS['lang'][$string] = $trans;
} else {
- $trans = false;
- if (!isset($installer) || $installer !== true) {
- $trans = getDynamicTranslation(
- $chaine,
- $language
- );
- }
- if ($trans) {
- $GLOBALS['lang'][$chaine] = $trans;
- } else {
- $trans = $chaine . ' (not translated)';
+ $trans = $string;
+ if ($nt === true) {
+ $trans .= ' (not translated)';
}
}
- return $trans;
- } else {
- return _($chaine);
}
+ return $trans;
+ } else {
+ return _($chaine);
}
}
+/**
+ * Translate a string, without displaying not translated
+ *
+ * @param string $string The string to translate
+ *
+ * @return Translated string (if available), verbatim string otherwise
+ */
+function __($string)
+{
+ return _T($string, false);
+}
+
/**********************************************
* some constant strings found in the database *
**********************************************/
import re
# pattern definition
-translatable= re.compile("_T\((\"[^\"]*\")\)")
+translatable= re.compile("_(T|_)\((\"[^\"]*\")\)")
tpl_translatable= re.compile("_T\ string=(\"[^\"]*\")")
# constants string
# search translatable strings
matchs = translatable.findall(line)
for match in matchs:
- if dico.has_key(match):
- if dico[match][-1:] == "\n":
- dico[match] += startLoc + location()
+ trans = match[1]
+ if dico.has_key(trans):
+ if dico[trans][-1:] == "\n":
+ dico[tans] += startLoc + location()
else :
- dico[match] += nextLoc + location() + "\n"
+ dico[trans] += nextLoc + location() + "\n"
else :
- dico[match] = startLoc + location()
+ dico[trans] = startLoc + location()
tpl_matchs = tpl_translatable.findall(line)
for tpl_match in tpl_matchs:
if dico.has_key(tpl_match):
else :
dico[tpl_match] = startLoc + location()
+print dico
#
-outFile = open("messages.po",'w')
+#outFile = open("messages.po",'w')
for k, v in dico.iteritems():
- outFile.write(v)
- if v[-1:] != "\n" :
- outFile.write("\n")
- outFile.write("msgid " + k + "\nmsgstr \"\"\n\n")
-outFile.close()
+ print v
+ print "msgid " + k + "\nmsgstr \"\"\n\n"
+# outFile.write(v)
+# if v[-1:] != "\n" :
+# outFile.write("\n")
+# outFile.write("msgid " + k + "\nmsgstr \"\"\n\n")
+#outFile.close()