-----------------------
+2018-08-13 Jürgen Spitzmüller <spitz@lyx.org>
+ * format incremented to 562: New info-inset type l7n. This returns a localized version
+ of a string (in the GUI language) if available, removing trailing colons and
+ accelerator marks.
+
2018-08-10 Kornel Benko <kornel@lyx.org>
* format incremented to 561: Added DejaVu fonts
i = i + 1
+def revert_l7ninfo(document):
+ " Revert l7n Info inset to text. "
+
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset Info", i)
+ if i == -1:
+ return
+ j = find_end_of_inset(document.body, i + 1)
+ if j == -1:
+ document.warning("Malformed LyX document: Could not find end of Info inset.")
+ i = i + 1
+ continue
+ tp = find_token(document.body, 'type', i, j)
+ tpv = get_quoted_value(document.body, "type", tp)
+ if tpv != "l7n":
+ i = i + 1
+ continue
+ arg = find_token(document.body, 'arg', i, j)
+ argv = get_quoted_value(document.body, "arg", arg)
+ # remove trailing colons, menu accelerator (|...) and qt accelerator (&), while keeping literal " & "
+ argv = argv.rstrip(':').split('|')[0].replace(" & ", "</amp;>").replace("&", "").replace("</amp;>", " & ")
+ document.body[i : j+1] = argv
+ i = i + 1
+
+
##
# Conversion hub
#
[558, [removeFrontMatterStyles]],
[559, []],
[560, []],
- [561, [convert_dejavu]]
+ [561, [convert_dejavu]],
+ [562, []]
]
revert = [
+ [561, [revert_l7ninfo]],
[560, [revert_dejavu]],
[559, [revert_timeinfo, revert_namenoextinfo]],
[558, [revert_dateinfo]],
the work area.\n
2. select the text and run info-insert lfun.
* \li Syntax: info-insert <TYPE> <ARG>
- * \li Params: <TYPE>: shortcut[s]|lyxrc|lyxinfo|package|textclass|menu|icon|buffer \n
+ * \li Params: <TYPE>: date|moddate|fixdate|time|modtime|fixtime|shortcut|shortcuts|lyxrc|
+ * lyxinfo|package|textclass|menu|l7n|icon|buffer|vcs \n
<ARG>: argument for a given type. Look into InsetInfo.h for detailed
description. \n
date: current date (formatted and localized)\n
package: name of latex package (e.g. listings) \n
textclass: name of textclass (e.g. article) \n
menu: name of lfun used in menu \n
+ l7n: localizable string.\n
icon: icon of lfun used in toolbar or direct icon name\n
buffer: "name"|"name-noext"|"path"|"class"
vcs: "tree-revision"|"revision"|"author"|"date"|"time"
"shortcut",
"shortcuts",
"menu",
+ "l7n",
"icon",
"lyxrc",
"lyxinfo",
N_("Last Assigned Keyboard Shortcut"),// shortcut
N_("All Keyboard Shortcuts"),// shortcuts
N_("LyX Menu Location"),// menu
+ N_("Localized GUI String"),// l7n
N_("LyX Toolbar Icon"),// icon
N_("LyX Preferences Entry"),// lyxrc
N_("LyX Application Information"),// lyxinfo
N_("LyX Function"),// shortcut
N_("LyX Function"),// shortcuts
N_("LyX Function"),// menu
+ N_("English String"),// l7n
N_("LyX Function"),// icon
N_("Preferences Key"),// lyxrc
N_("Not Applicable"),// lyxinfo
"The output lists all possible keyboard shortcuts for this function"),// shortcuts
N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
"The output is the path to the function in the menu (using the current localization)."),// menu
+ N_("Enter a localizable English string from the LyX User Interface, including accelerator markup ('&' or '|') and trailing colons. "
+ "The output is the localized string (using the current localization); trailing colons and accelerator markup are stripped."),// l7n
N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
"The output is the toolbar icon for this function (using the active icon theme)."),// icon
N_("Enter a LyX preferences key such as 'bind_file'. See the proposed list for available entries. "
translator.addPair(InsetInfoParams::PACKAGE_INFO, "package");
translator.addPair(InsetInfoParams::TEXTCLASS_INFO, "textclass");
translator.addPair(InsetInfoParams::MENU_INFO, "menu");
+ translator.addPair(InsetInfoParams::L7N_INFO, "l7n");
translator.addPair(InsetInfoParams::ICON_INFO, "icon");
translator.addPair(InsetInfoParams::BUFFER_INFO, "buffer");
translator.addPair(InsetInfoParams::LYX_INFO, "lyxinfo");
translator.addPair(InsetInfoParams::PACKAGE_INFO, "graphics");
translator.addPair(InsetInfoParams::TEXTCLASS_INFO, "article");
translator.addPair(InsetInfoParams::MENU_INFO, "info-insert");
+ translator.addPair(InsetInfoParams::L7N_INFO, "");
translator.addPair(InsetInfoParams::ICON_INFO, "info-insert");
translator.addPair(InsetInfoParams::BUFFER_INFO, "name-noext");
translator.addPair(InsetInfoParams::LYX_INFO, "version");
break;
}
+ case L7N_INFO:
+ result.push_back(make_pair("custom", _("Custom")));
+ break;
+
case LYXRC_INFO: {
result.push_back(make_pair("custom", _("Custom")));
set<string> rcs = lyxrc.getRCs();
result = bformat(_("The menu location for the function '%1$s'"),
from_utf8(params_.name));
break;
+ case InsetInfoParams::L7N_INFO:
+ result = bformat(_("The localization for the string '%1$s'"),
+ from_utf8(params_.name));
+ break;
case InsetInfoParams::ICON_INFO:
result = bformat(_("The toolbar icon for the function '%1$s'"),
from_utf8(params_.name));
return func.action() != LFUN_UNKNOWN_ACTION;
}
+ case InsetInfoParams::L7N_INFO:
+ return !name.empty();
+
case InsetInfoParams::ICON_INFO: {
FuncCode const action = lyxaction.lookupFunc(name).action();
if (action == LFUN_UNKNOWN_ACTION) {
}
break;
}
+ case InsetInfoParams::L7N_INFO: {
+ docstring locstring = _(params_.name);
+ // Remove trailing colons
+ locstring = rtrim(locstring, ":");
+ // Remove menu accelerators
+ if (contains(locstring, from_ascii("|"))) {
+ docstring nlocstring;
+ rsplit(locstring, nlocstring, '|');
+ locstring = nlocstring;
+ }
+ // Remove Qt accelerators, but keep literal ampersands
+ locstring = subst(locstring, from_ascii(" & "), from_ascii("</amp;>"));
+ locstring = subst(locstring, from_ascii("&"), docstring());
+ locstring = subst(locstring, from_ascii("</amp;>"), from_ascii(" & "));
+ setText(locstring, guilang);
+ params_.force_ltr = !guilang->rightToLeft() && !params_.lang->rightToLeft();
+ break;
+ }
case InsetInfoParams::ICON_INFO: {
// only need to do this once.
if (initialized_)
triggers this LFUN. For example, "File > Paste", where '>' is actually
\lyxarrow (an InsetSpecialChar).
+l7n: argument is an English string that is marked for localization. The output
+ is the localization of that string in the current GUI language (if available).
+ Trailing colons are stripped, accelerators removed.
+ This is used to refer to GUI items in the docs.
+
icon: argument is the name of the LFUN such as "paste". The syntax is the same
as what is used in the bind and ui files. The output is the icon use in
the toolbar for this LFUN. Alternatively, argument can be the icon path
MENU_INFO, // Which menu item is used for certain function
ICON_INFO, // which toolbar icon is used for certain function
LYX_INFO, // LyX version information
+ L7N_INFO, // Localized string
UNKNOWN_INFO, // Invalid type
};
///
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 561 // kornel: Added dejavu fonts
-#define LYX_FORMAT_TEX2LYX 561
+#define LYX_FORMAT_LYX 562 // spitz: l7n info inset
+#define LYX_FORMAT_TEX2LYX 562
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER