Utility for localization
The plugin contains a utility for adding localization to user packets of scripts. The utility consists of two files:
<plugin_directory>/lf4ed_lang.lua
and far2/makelang.lua
.
(1) Create a “language template” file (similar to lf4ed_lang.templ
file in the plugin directory), let’s assume it is scripts/my_package/lang.templ.
The exact syntax of “language template” files is described in the file
far2/makelang.lua
. The template file should be in UTF-8 encoding, with or without BOM.Choose some prefix for all your message identifiers (e.g. “mp”), to avoid conflicts with the existing message identifiers (if conflicts occur, they are detected by the program).
Every script using this message system should
require "lf4ed_message"
. This returns a table that can be accessed for retrieving localized messages.
(2) Run the following command from the plugin’s directory:
lua lf4ed_lang.lua scripts/my_package/lang.templ
If no errors occured, this will extend *.lng
files and lf4ed_message.lua
file with the localized messages of your script package.
(3) Restart Far.
Example of use:
local M = require "lf4ed_message"
........
far.Message(M.mpSomeMsgText, M.mpSomeMsgTitle, M.mpSomeMsgButtons)