diff options
author | 2010-10-15 16:52:12 -0400 | |
---|---|---|
committer | 2010-10-15 16:52:12 -0400 | |
commit | 6d11c044ec0059405c9e2813e39e9b618e7068c8 (patch) | |
tree | bd2d28c04d63d633817cc1f29c74608e36c7c3cb | |
parent | 32602279973cef2783399c08709b3567f8369371 (diff) | |
download | textadept-6d11c044ec0059405c9e2813e39e9b618e7068c8.tar.gz textadept-6d11c044ec0059405c9e2813e39e9b618e7068c8.zip |
Changed locale implementation.
-rw-r--r-- | core/.gui.luadoc | 4 | ||||
-rw-r--r-- | core/events.lua | 31 | ||||
-rw-r--r-- | core/file_io.lua | 23 | ||||
-rw-r--r-- | core/gui.lua | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | core/locale.conf | 805 | ||||
-rw-r--r-- | core/locale.lua | 15 | ||||
-rw-r--r-- | modules/textadept/editing.lua | 25 | ||||
-rw-r--r-- | modules/textadept/find.lua | 32 | ||||
-rw-r--r-- | modules/textadept/keys.lua | 12 | ||||
-rw-r--r-- | modules/textadept/menu.lua | 254 | ||||
-rw-r--r-- | modules/textadept/mime_types.lua | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | modules/textadept/run.lua | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | modules/textadept/session.lua | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | modules/textadept/snapopen.lua | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | modules/textadept/snippets.lua | 4 |
15 files changed, 395 insertions, 848 deletions
diff --git a/core/.gui.luadoc b/core/.gui.luadoc index eecc6c1d..9173b6e2 100644 --- a/core/.gui.luadoc +++ b/core/.gui.luadoc @@ -62,8 +62,8 @@ function check_focused_buffer(buffer) end -- buffer, and prints to it. -- @param buffer_type String type of message buffer. -- @param ... Message strings. --- @usage gui._print(locale.ERROR_BUFFER, error_message) --- @usage gui._print(locale.MESSAGE_BUFFER, message) +-- @usage gui._print(L('[Error Buffer]'), error_message) +-- @usage gui._print(L('[Message Buffer]'), message) function _print(buffer_type, ...) end --- diff --git a/core/events.lua b/core/events.lua index 96cb082b..4c67d37e 100644 --- a/core/events.lua +++ b/core/events.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize --- -- Textadept's core event structure and handlers. @@ -294,7 +294,7 @@ connect('buffer_new', -- @param buffer The currently focused buffer. local function set_title(buffer) local buffer = buffer - local filename = buffer.filename or buffer._type or locale.UNTITLED + local filename = buffer.filename or buffer._type or L('Untitled') local dirty = buffer.dirty and '*' or '-' gui.title = string.format('%s %s Textadept (%s)', filename:match('[^/\\]+$'), dirty, filename) @@ -332,11 +332,8 @@ connect('uri_dropped', end end) -local EOLs = { - locale.STATUS_CRLF, - locale.STATUS_CR, - locale.STATUS_LF -} +local string_format = string.format +local EOLs = { L('CRLF'), L('CR'), L('LF') } local GETLEXERLANGUAGE = _SCINTILLA.functions.get_lexer_language[1] connect('update_ui', function() -- sets docstatusbar text @@ -346,12 +343,12 @@ connect('update_ui', local col = buffer.column[pos] + 1 local lexer = buffer:private_lexer_call(GETLEXERLANGUAGE) local eol = EOLs[buffer.eol_mode + 1] - local tabs = (buffer.use_tabs and locale.STATUS_TABS or - locale.STATUS_SPACES)..buffer.indent + local tabs = string_format('%s %d', buffer.use_tabs and L('Tabs:') or + L('Spaces:'), buffer.indent) local enc = buffer.encoding or '' - gui.docstatusbar_text = locale.DOCSTATUSBAR_TEXT:format(line, max, col, - lexer, eol, tabs, - enc) + gui.docstatusbar_text = + string_format('%s %d/%d %s %d %s %s %s %s', L('Line:'), + line, max, L('Col:'), col, lexer, eol, tabs, enc) end) connect('margin_click', @@ -415,18 +412,18 @@ connect('quit', local list = {} for _, buffer in ipairs(_BUFFERS) do if buffer.dirty then - list[#list + 1] = buffer.filename or buffer._type or locale.UNTITLED + list[#list + 1] = buffer.filename or buffer._type or L('Untitled') any = true end end if any and gui.dialog('msgbox', - '--title', locale.EVENTS_QUIT_TITLE, - '--text', locale.EVENTS_QUIT_TEXT, + '--title', L('Quit without saving?'), + '--text', L('The following buffers are unsaved:'), '--informative-text', string.format('%s', table.concat(list, '\n')), '--button1', 'gtk-cancel', - '--button2', locale.EVENTS_QUIT_BUTTON2, + '--button2', L('Quit _without saving'), '--no-newline') ~= '2' then return false end @@ -446,4 +443,4 @@ if MAC then end) end -connect('error', function(...) gui._print(locale.ERROR_BUFFER, ...) end) +connect('error', function(...) gui._print(L('[Error Buffer]'), ...) end) diff --git a/core/file_io.lua b/core/file_io.lua index b395984a..89d3e5d7 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize local events = _G.events --- @@ -148,7 +148,7 @@ local function open_helper(utf8_filename) break end end - if not encoding then error(locale.IO_ICONV_ERROR) end + if not encoding then error(L('Encoding conversion failed.')) end end else encoding = nil @@ -190,7 +190,7 @@ end function open_file(utf8_filenames) utf8_filenames = utf8_filenames or gui.dialog('fileselect', - '--title', locale.IO_OPEN_TITLE, + '--title', L('Open'), '--select-multiple', '--with-directory', (buffer.filename or ''):match('.+[/\\]') or '') @@ -264,7 +264,7 @@ local function save_as(buffer, utf8_filename) gui.check_focused_buffer(buffer) if not utf8_filename then utf8_filename = gui.dialog('filesave', - '--title', locale.IO_SAVE_TITLE, + '--title', L('Save'), '--with-directory', (buffer.filename or ''):match('.+[/\\]') or '', '--with-file', @@ -297,13 +297,13 @@ local function close(buffer) gui.check_focused_buffer(buffer) if buffer.dirty and gui.dialog('msgbox', - '--title', locale.IO_CLOSE_TITLE, - '--text', locale.IO_CLOSE_TEXT, + '--title', L('Close without saving?'), + '--text', L('There are unsaved changes in'), '--informative-text', string.format('%s', (buffer.filename or - buffer._type or locale.UNTITLED)), + buffer._type or L('Untitled'))), '--button1', 'gtk-cancel', - '--button2', locale.IO_CLOSE_BUTTON2, + '--button2', L('Close _without saving'), '--no-newline') ~= '2' then return false end @@ -336,10 +336,11 @@ local function update_modified_file() if not attributes then return end if buffer.modification_time < attributes.modification then if gui.dialog('yesno-msgbox', - '--title', locale.IO_RELOAD_TITLE, - '--text', locale.IO_RELOAD_TEXT, + '--title', L('Reload?'), + '--text', L('Reload modified file?'), '--informative-text', - string.format(locale.IO_RELOAD_MSG, utf8_filename), + string.format('"%s"\n%s', utf8_filename, + L('has been modified. Reload it?')), '--no-cancel', '--no-newline') == '1' then buffer:reload() diff --git a/core/gui.lua b/core/gui.lua index b18b7afd..ef9892cc 100644 --- a/core/gui.lua +++ b/core/gui.lua @@ -1,13 +1,14 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local L = _G.locale.localize local gui = _G.gui -- LuaDoc is in core/.gui.lua. function gui.check_focused_buffer(buffer) if type(buffer) ~= 'table' or not buffer.doc_pointer then - error(locale.ERR_BUFFER_EXPECTED, 2) + error(L('Buffer argument expected.'), 2) elseif gui.focused_doc_pointer ~= buffer.doc_pointer then - error(locale.ERR_BUFFER_NOT_FOCUSED, 2) + error(L('The indexed buffer is not the focused one.'), 2) end end @@ -48,19 +49,19 @@ function gui._print(buffer_type, ...) end -- LuaDoc is in core/.gui.lua. -function gui.print(...) gui._print(locale.MESSAGE_BUFFER, ...) end +function gui.print(...) gui._print(L('[Message Buffer]'), ...) end -- LuaDoc is in core/.gui.lua. function gui.switch_buffer() local items = {} for _, buffer in ipairs(_BUFFERS) do - local filename = buffer.filename or buffer._type or locale.UNTITLED + local filename = buffer.filename or buffer._type or L('Untitled') local dirty = buffer.dirty and '*' or '' items[#items + 1] = dirty..filename:match('[^/\\]+$') items[#items + 1] = filename end local response = gui.dialog('filteredlist', - '--title', locale.SWITCH_BUFFERS, + '--title', L('Switch Buffers'), '--button1', 'gtk-ok', '--button2', 'gtk-cancel', '--no-newline', diff --git a/core/locale.conf b/core/locale.conf index d6df2c3f..c83a8023 100644..100755 --- a/core/locale.conf +++ b/core/locale.conf @@ -6,663 +6,196 @@ % you use the \ddd repesentation of characters, it must be in DECIMAL format, % not Octal. % -% Each line contains a message ID (in capital letters) followed by the localized -% string in double-quotation marks (""). The message ID should not be localized. -% For reference, the first commented line is the file where the localized string -% appears in; the second is the English version of the string. +% Each line contains a "message = localized string" pair. The message should not +% be localized. Extra spaces around '=' are ignored. % % Notes: -% - Double quotations inside the localized string need not be escaped. -% - Please do not localize the %d, %s, etc. % - gtk-* strings do not need to be localized; GTK will do it for you based % on your system's locale settings. % - Menu items have a "_" character as a mnemonic (for Alt+character) access. % You can put the "_" anywhere applicable in your localized version. % core/events.lua -% "Untitled" -UNTITLED "Untitled" - -% core/events.lua -% "[Message Buffer]" -MESSAGE_BUFFER "[Message Buffer]" - -% core/events.lua -% "CRLF" -STATUS_CRLF "CRLF" - -% core/events.lua -% "CR" -STATUS_CR "CR" - -% core/events.lua -% "LF" -STATUS_LF "LF" - -% core/events.lua -% "Tabs: " -STATUS_TABS "Tabs: " - -% core/events.lua -% "Spaces: " -STATUS_SPACES "Spaces: " - -% core/events.lua -% "Line: %d/%d Col: %d %s %s %s %s" -DOCSTATUSBAR_TEXT "Line: %d/%d Col: %d %s %s %s %s" - -% core/events.lua -% "Quit without saving?" -EVENTS_QUIT_TITLE "Quit without saving?" - -% core/events.lua -% "The following buffers are unsaved:" -EVENTS_QUIT_TEXT "The following buffers are unsaved:" - -% core/events.lua -% "Quit _without saving" -EVENTS_QUIT_BUTTON2 "Quit _without saving" - -% core/events.lua -% "[Error Buffer]" -ERROR_BUFFER "[Error Buffer]" - -% core/file_io.lua -% "Encoding conversion failed." -IO_ICONV_ERROR "Encoding conversion failed." - -% core/file_io.lua -% "Open" -IO_OPEN_TITLE "Open" - -% core/file_io.lua -% "Save" -IO_SAVE_TITLE "Save" - -% core/file_io.lua -% "Close without saving?" -IO_CLOSE_TITLE "Close without saving?" - -% core/file_io.lua -% "There are unsaved changes in" -IO_CLOSE_TEXT "There are unsaved changes in" - -% core/file_io.lua -% "Close _without saving" -IO_CLOSE_BUTTON2 "Close _without saving" - -% core/file_io.lua -% "Reload?" -IO_RELOAD_TITLE "Reload?" - -% core/file_io.lua -% "Reload modified file?" -IO_RELOAD_TEXT "Reload modified file?" +Untitled = Untitled +[Message Buffer] = [Message Buffer] +CRLF = CRLF +CR = CR +LF = LF +Tabs: = Tabs: +Spaces: = Spaces: +Line: = Line: +Col: = Col: +Quit without saving? = Quit without saving? +The following buffers are unsaved: = The following buffers are unsaved: +Quit _without saving = Quit _without saving +[Error Buffer] = [Error Buffer] % core/file_io.lua -% ""%s"\nhas been modified outside of Textadept.\nReload it to reflect the newest version?" -IO_RELOAD_MSG ""%s"\nhas been modified outside of Textadept.\nReload it to reflect the newest version?" - -% core/init.lua -% "Buffer argument expected." -ERR_BUFFER_EXPECTED "Buffer argument expected." - -% core/init.lua -% "The indexed buffer is not the focused one." -ERR_BUFFER_NOT_FOCUSED "The indexed buffer is not the focused one." - -% core/init.lua -% "Switch Buffers" -SWITCH_BUFFERS "Switch Buffers" - -% modules/textadept/find.lua -% Search wrapped -FIND_SEARCH_WRAPPED "Search wrapped" - -% modules/textadept/find.lua -% "No results found" -FIND_NO_RESULTS "No results found" - -% modules/textadept/find.lua -% "Error" -FIND_ERROR_DIALOG_TITLE "Error" - -% modules/textadept/find.lua -% "An error occured:" -FIND_ERROR_DIALOG_TEXT "An error occured" - -% modules/textadept/find.lua -% "%d replacement(s) made" -FIND_REPLACEMENTS_MADE "%d replacement(s) made" - -% modules/textadept/find.lua -% "Find in Files" -FIND_IN_FILES_TITLE "Find in Files" - -% modules/textadept/find.lua -% "[Files Found Buffer]" -FIND_FILES_FOUND_BUFFER "[Files Found Buffer]" - -% modules/textadept/keys.lua -% "Keychain: " -KEYCHAIN "Keychain: " - -% modules/textadept/keys.lua -% "Invalid sequence" -KEYS_INVALID "Invalid sequence" +Encoding conversion failed. = Encoding conversion failed. +Open = Open +Save = Save +Close without saving? = Close without saving? +There are unsaved changes in = There are unsaved changes in +Close _without saving = Close _without saving +Reload? = Reload? +Reload modified file? = Reload modified file? +has been modified. Reload it? = has been modified. Reload it? + +% core/gui.lua +Buffer argument expected. = Buffer argument expected. +The indexed buffer is not the focused one. = The indexed buffer is not the focused one. +Switch Buffers = Switch Buffers +Search wrapped = Search wrapped + +% core/find.lua +No results found = No results found +Error = Error +An error occured: = An error occured: +replacement(s) made = replacement(s) made +Find in Files = Find in Files +[Files Found Buffer] = [Files Found Buffer] % modules/textadept/keys.lua -% "Unknown command: " -KEYS_UNKNOWN_COMMAND "Unknown command: " - -% modules/textadept/menu.lua -% "_File" -MENU_FILE_TITLE "_File" - -% modules/textadept/menu.lua -% "gtk-new" -MENU_FILE_NEW "gtk-new" - -% modules/textadept/menu.lua -% "gtk-open" -MENU_FILE_OPEN "gtk-open" - -% modules/textadept/menu.lua -% "_Reload" -MENU_FILE_RELOAD "_Reload" - -% modules/textadept/menu.lua -% "gtk-save" -MENU_FILE_SAVE "gtk-save" - -% modules/textadept/menu.lua -% "gtk-save-as" -MENU_FILE_SAVEAS "gtk-save-as" - -% modules/textadept/menu.lua -% "gtk-close" -MENU_FILE_CLOSE "gtk-close" - -% modules/textadept/menu.lua -% "Close A_ll" -MENU_FILE_CLOSE_ALL "Close A_ll" - -% modules/textadept/menu.lua -% "Loa_d Session..." -MENU_FILE_LOAD_SESSION "Loa_d Session..." - -% modules/textadept/menu.lua -% "Sa_ve Session..." -MENU_FILE_SAVE_SESSION "Sa_ve Session..." - -% modules/textadept/menu.lua -% "gtk-quit" -MENU_FILE_QUIT "gtk-quit" - -% modules/textadept/menu.lua -% "_Edit" -MENU_EDIT_TITLE "_Edit" - -% modules/textadept/menu.lua -% "gtk-undo" -MENU_EDIT_UNDO "gtk-undo" - -% modules/textadept/menu.lua -% "gtk-redo" -MENU_EDIT_REDO "gtk-redo" - -% modules/textadept/menu.lua -% "gtk-cut" -MENU_EDIT_CUT "gtk-cut" - -% modules/textadept/menu.lua -% "gtk-copy" -MENU_EDIT_COPY "gtk-copy" - -% modules/textadept/menu.lua -% "gtk-paste" -MENU_EDIT_PASTE "gtk-paste" - -% modules/textadept/menu.lua -% "gtk-delete" -MENU_EDIT_DELETE "gtk-delete" - -% modules/textadept/menu.lua -% "gtk-select-all" -MENU_EDIT_SELECT_ALL "gtk-select-all" - -% modules/textadept/menu.lua -% "Match _Brace" -MENU_EDIT_MATCH_BRACE "Match _Brace" - -% modules/textadept/menu.lua -% "Select t_o Brace" -MENU_EDIT_SELECT_TO_BRACE "Select t_o Brace" - -% modules/textadept/menu.lua -% "Complete _Word" -MENU_EDIT_COMPLETE_WORD "Complete _Word" - -% modules/textadept/menu.lua -% "De_lete Word" -MENU_EDIT_DELETE_WORD "De_lete Word" - -% modules/textadept/menu.lua -% "Tran_spose Characters" -MENU_EDIT_TRANSPOSE_CHARACTERS "Tran_spose Characters" - -% modules/textadept/menu.lua -% "S_queeze" -MENU_EDIT_SQUEEZE "S_queeze" - -% modules/textadept/menu.lua -% "_Join Lines" -MENU_EDIT_JOIN_LINES "_Join Lines" - -% modules/textadept/menu.lua -% "Convert _Indentation" -MENU_EDIT_CONVERT_INDENTATION "Convert _Indentation" - -% modules/textadept/menu.lua -% "S_election" -MENU_EDIT_SEL_TITLE "S_election" - -% modules/textadept/menu.lua -% "_Enclose in..." -MENU_EDIT_SEL_ENC_TITLE "_Enclose in..." - -% modules/textadept/menu.lua -% "_HTML Tags" -MENU_EDIT_SEL_ENC_HTML_TAGS "_HTML Tags" - -% modules/textadept/menu.lua -% "HTML Single _Tag" -MENU_EDIT_SEL_ENC_HTML_SINGLE_TAG "HTML Single _Tag" - -% modules/textadept/menu.lua -% "_Double Quotes" -MENU_EDIT_SEL_ENC_DOUBLE_QUOTES "_Double Quotes" - -% modules/textadept/menu.lua -% "_Single Quotes" -MENU_EDIT_SEL_ENC_SINGLE_QUOTES "_Single Quotes" - -% modules/textadept/menu.lua -% "_Parentheses" -MENU_EDIT_SEL_ENC_PARENTHESES "_Parentheses" - -% modules/textadept/menu.lua -% "_Brackets" -MENU_EDIT_SEL_ENC_BRACKETS "_Brackets" - -% modules/textadept/menu.lua -% "B_races" -MENU_EDIT_SEL_ENC_BRACES "B_races" - -% modules/textadept/menu.lua -% "_Character Sequence" -MENU_EDIT_SEL_ENC_CHAR_SEQ "_Character Sequence" - -% modules/textadept/menu.lua -% "_Grow" -MENU_EDIT_SEL_GROW "_Grow" - -% modules/textadept/menu.lua -% "Select i_n..." -MENU_EDIT_SEL_IN_TITLE "Select i_n..." - -% modules/textadept/menu.lua -% "_HTML Tag" -MENU_EDIT_SEL_IN_HTML_TAG "_HTML Tag" - -% modules/textadept/menu.lua -% "_Double Quote" -MENU_EDIT_SEL_IN_DOUBLE_QUOTE "_Double Quote" - -% modules/textadept/menu.lua -% "_Single Quote" -MENU_EDIT_SEL_IN_SINGLE_QUOTE "_Single Quote" - -% modules/textadept/menu.lua -% "_Parenthesis" -MENU_EDIT_SEL_IN_PARENTHESIS "_Parenthesis" - -% modules/textadept/menu.lua -% "_Bracket" -MENU_EDIT_SEL_IN_BRACKET "_Bracket" - -% modules/textadept/menu.lua -% "B_race" -MENU_EDIT_SEL_IN_BRACE "B_race" - -% modules/textadept/menu.lua -% "_Word" -MENU_EDIT_SEL_IN_WORD "_Word" - -% modules/textadept/menu.lua -% "_Line" -MENU_EDIT_SEL_IN_LINE "_Line" - -% modules/textadept/menu.lua -% "Para_graph" -MENU_EDIT_SEL_IN_PARAGRAPH "Para_graph" - -% modules/textadept/menu.lua -% "_Indented Block" -MENU_EDIT_SEL_IN_INDENTED_BLOCK "_Indented Block" - -% modules/textadept/menu.lua -% "S_cope" -MENU_EDIT_SEL_IN_SCOPE "S_cope" - -% modules/textadept/menu.lua -% "_Tools" -MENU_TOOLS_TITLE "_Tools" - -% modules/textadept/menu.lua -% "_Find" -MENU_TOOLS_SEARCH_TITLE "_Find" - -% modules/textadept/menu.lua -% "gtk-find" -MENU_TOOLS_SEARCH_FIND "gtk-find" - -% modules/textadept/menu.lua -% "Find _Next" -MENU_TOOLS_SEARCH_FIND_NEXT "Find _Next" - -% modules/textadept/menu.lua -% "Find _Previous" -MENU_TOOLS_SEARCH_FIND_PREV "Find _Previous" - -% modules/textadept/menu.lua -% "gtk-find-and-replace" -MENU_TOOLS_SEARCH_FIND_AND_REPLACE "gtk-find-and-replace" - -% modules/textadept/menu.lua -% "Replace" -MENU_TOOLS_SEARCH_REPLACE "Replace" - -% modules/textadept/menu.lua -% "Replace _All" -MENU_TOOLS_SEARCH_REPLACE_ALL "Replace _All" - -% modules/textadept/menu.lua -% "Find _Incremental" -MENU_TOOLS_SEARCH_FIND_INCREMENTAL "Find _Incremental" - -% modules/textadept/menu.lua -% "Find in Fi_les" -MENU_TOOLS_SEARCH_FIND_IN_FILES "Find in Fi_les" - -% modules/textadept/menu.lua -% "Goto Next File Found" -MENU_TOOLS_SEARCH_GOTO_NEXT_FILE_FOUND "Goto Next File Found" - -% modules/textadept/menu.lua -% "Goto Previous File Found" -MENU_TOOLS_SEARCH_GOTO_PREV_FILE_FOUND "Goto Previous File Found" - -% modules/textadept/menu.lua -% "gtk-jump-to" -MENU_TOOLS_SEARCH_GOTO_LINE "gtk-jump-to" - -% modules/textadept/menu.lua -% "Command _Entry" -MENU_TOOLS_FOCUS_COMMAND_ENTRY "Command _Entry" - -% modules/textadept/menu.lua -% "_Run" -MENU_TOOLS_RUN "_Run" - -% modules/textadept/menu.lua -% "_Compile" -MENU_TOOLS_COMPILE "_Compile" - -% modules/textadept/menu.lua -% "_Snippets" -MENU_TOOLS_SNIPPETS_TITLE "_Snippets" - -% modules/textadept/menu.lua -% "_Insert Snippet" -MENU_TOOLS_SNIPPETS_INSERT "_Insert" - -% modules/textadept/menu.lua -% "_Previous Placeholder" -MENU_TOOLS_SNIPPETS_PREV_PLACE "_Previous Placeholder" - -% modules/textadept/menu.lua -% "_Cancel" -MENU_TOOLS_SNIPPETS_CANCEL "_Cancel" - -% modules/textadept/menu.lua -% "_List" -MENU_TOOLS_SNIPPETS_LIST "_List" - -% modules/textadept/menu.lua -% "_Show Scope" -MENU_TOOLS_SNIPPETS_SHOW_SCOPE "_Show Scope" - -% modules/textadept/menu.lua -% "_Bookmark" -MENU_TOOLS_BM_TITLE "_Bookmark" - -% modules/textadept/menu.lua -% "_Toggle on Current Line" -MENU_TOOLS_BM_TOGGLE "_Toggle on Current Line" - -% modules/textadept/menu.lua -% "_Clear All" -MENU_TOOLS_BM_CLEAR_ALL "_Clear All" - -% modules/textadept/menu.lua -% "_Next" -MENU_TOOLS_BM_NEXT "_Next" - -% modules/textadept/menu.lua -% "_Previous" -MENU_TOOLS_BM_PREV "_Previous" - -% modules/textadept/menu.lua -% "Snap_open" -MENU_TOOLS_SNAPOPEN_TITLE "Snap_open" - -% modules/textadept/menu.lua -% "Snap_open" -MENU_TOOLS_SNAPOPEN_USERHOME "_User Home" - -% modules/textadept/menu.lua -% "Snap_open" -MENU_TOOLS_SNAPOPEN_HOME "_Textadept Home" - -% modules/textadept/menu.lua -% "Snap_open" -MENU_TOOLS_SNAPOPEN_CURRENTDIR "_Current Directory" - -% modules/textadept/menu.lua -% "_Buffer" -MENU_BUF_TITLE "_Buffer" - -% modules/textadept/menu.lua -% "_Next Buffer" -MENU_BUF_NEXT "_Next Buffer" - -% modules/textadept/menu.lua -% "_Previous Buffer" -MENU_BUF_PREV "_Previous Buffer" - -% modules/textadept/menu.lua -% "S_witch Buffer" -MENU_BUF_SWITCH "Swit_ch Buffer" - -% modules/textadept/menu.lua -% "Toggle View _EOL" -MENU_BUF_TOGGLE_VIEW_EOL "Toggle View _EOL" - -% modules/textadept/menu.lua -% "Toggle _Wrap Mode" -MENU_BUF_TOGGLE_WRAP "Toggle _Wrap Mode" - -% modules/textadept/menu.lua -% "Toggle Show _Indentation Guides" -MENU_BUF_TOGGLE_INDENT_GUIDES "Toggle Show _Indentation Guides" - -% modules/textadept/menu.lua -% "Toggle Use _Tabs" -MENU_BUF_TOGGLE_TABS "Toggle Use _Tabs" - -% modules/textadept/menu.lua -% "Toggle View White_space" -MENU_BUF_TOGGLE_VIEW_WHITESPACE "Toggle View White_space" - -% modules/textadept/menu.lua -% "EOL Mode" -MENU_BUF_EOL_MODE_TITLE "EOL Mode" - -% modules/textadept/menu.lua -% "CR+LF" -MENU_BUF_EOL_MODE_CRLF "CR+LF" - -% modules/textadept/menu.lua -% "CR" -MENU_BUF_EOL_MODE_CR "CR" - -% modules/textadept/menu.lua -% "LF" -MENU_BUF_EOL_MODE_LF "LF" - -% modules/textadept/menu.lua -% "Encoding" -MENU_BUF_ENCODING_TITLE "Encoding" - -% modules/textadept/menu.lua -% "UTF-8" -MENU_BUF_ENCODING_UTF8 "UTF-8" - -% modules/textadept/menu.lua -% "ASCII" -MENU_BUF_ENCODING_ASCII "ASCII" - -% modules/textadept/menu.lua -% "ISO-8859-1" -MENU_BUF_ENCODING_ISO88591 "ISO-8859-1" - -% modules/textadept/menu.lua -% "MacRoman" -MENU_BUF_ENCODING_MACROMAN "MacRoman" - -% modules/textadept/menu.lua -% "UTF-16" -MENU_BUF_ENCODING_UTF16 "UTF-16" - -% modules/textadept/menu.lua -% "_Refresh Syntax Highlighting" -MENU_BUF_REFRESH "_Refresh Syntax Highlighting" - -% modules/textadept/menu.lua -% "_View" -MENU_VIEW_TITLE "_View" - -% modules/textadept/menu.lua -% "_Next View" -MENU_VIEW_NEXT "_Next View" - -% modules/textadept/menu.lua -% "_Previous View" -MENU_VIEW_PREV "_Previous View" - -% modules/textadept/menu.lua -% "Split _Vertical" -MENU_VIEW_SPLIT_VERTICAL "Split _Vertical" - -% modules/textadept/menu.lua -% "Split _Horizontal" -MENU_VIEW_SPLIT_HORIZONTAL "Split _Horizontal" - -% modules/textadept/menu.lua -% "_Unsplit" -MENU_VIEW_UNSPLIT "_Unsplit" - -% modules/textadept/menu.lua -% "Unsplit _All" -MENU_VIEW_UNSPLIT_ALL "Unsplit _All" - -% modules/textadept/menu.lua -% "_Grow" -MENU_VIEW_GROW "_Grow" - -% modules/textadept/menu.lua -% "_Shrink" -MENU_VIEW_SHRINK "_Shrink" - -% modules/textadept/menu.lua -% "Le_xers" -MENU_LEX_TITLE "Le_xers" - -% modules/textadept/menu.lua -% "_Help" -MENU_HELP_TITLE "_Help" - -% modules/textadept/menu.lua -% "_Manual" -MENU_HELP_MANUAL "_Manual" - -% modules/textadept/menu.lua -% "_LuaDoc" -MENU_HELP_LUADOC "_LuaDoc" - -% modules/textadept/menu.lua -% "gtk-about" -MENU_HELP_ABOUT "gtk-about" - -% modules/textadept/menu.lua -% "Error loading webpage: " -MENU_BROWSER_ERROR "Error loading webpage: " - -% modules/textadept/menu.lua -% "Load Session" -MENU_LOAD_SESSION_TITLE "Load Session" - -% modules/textadept/menu.lua -% "Save Session" -MENU_SAVE_SESSION_TITLE "Save Session" - -% modules/textadept/menu.lua -% "Unknown command: " -MENU_UNKNOWN_COMMAND "Unknown command: " +Keychain: = Keychain: +Invalid sequence = Invalid sequence +Unknown command: = Unknown command: + +% modules/textadept/menu.lua +_File = _File +gtk-new = gtk-new +gtk-open = gtk-open +_Reload = _Reload +gtk-save = gtk-save +gtk-save-as = gtk-save-as +gtk-close = gtk-close +Close A_ll = Close A_ll +Loa_d Session... = Loa_d Session... +Sa_ve Session... = Sa_ve Session... +gtk-quit = gtk-quit + +_Edit = _Edit +gtk-undo = gtk-undo +gtk-redo = gtk-redo +gtk-cut = gtk-cut +gtk-copy = gtk-copy +gtk-paste = gtk-paste +gtk-delete = gtk-delete +gtk-select-all = gtk-select-all +Match _Brace = Match _Brace +Select t_o Brace = Select t_o Brace +Complete _Word = Complete _Word +De_lete Word = De_lete Word +Tran_spose Characters = Tran_spose Characters +_Join Lines = _Join Lines +Convert _Indentation = Convert _Indentation +S_election = S_election +_Enclose in... = _Enclose in... +_HTML Tags = _HTML Tags +HTML Single _Tag = HTML Single _Tag +_Double Quotes = _Double Quotes +_Single Quotes = _Single Quotes +_Parentheses = _Parentheses +_Brackets = _Brackets +B_races = B_races +_Character Sequence = _Character Sequence +_Grow = _Grow +Select i_n... = Select i_n... +_HTML Tag = _HTML Tag +_Double Quote = _Double Quote +_Single Quote = _Single Quote +_Parenthesis = _Parenthesis +_Bracket = _Bracket +B_race = B_race +_Word = _Word +_Line = _Line +Para_graph = Para_graph +_Indented Block = _Indented Block +S_cope = S_cope +_Tools = _Tools +_Find = _Find +gtk-find = gtk-find +Find _Next = Find _Next +Find _Previous = Find _Previous +gtk-find-and-replace = gtk-find-and-replace +Replace = Replace +Replace _All = Replace _All +Find _Incremental = Find _Incremental +Find in Fi_les = Find in Fi_les +Goto Next File Found = Goto Next File Found +Goto Previous File Found = Goto Previous File Found +gtk-jump-to = gtk-jump-to +Command _Entry = Command _Entry +_Run = _Run +_Compile = _Compile +_Snippets = _Snippets +_Insert = _Insert +_Previous Placeholder = _Previous Placeholder +_Cancel = _Cancel +_List = _List +_Show Scope = _Show Scope +_Bookmark = _Bookmark +_Toggle on Current Line = _Toggle on Current Line +_Clear All = _Clear All +_Next = _Next +_Previous = _Previous +Snap_open = Snap_open +_User Home = _User Home +_Textadept Home = _Textadept Home +_Current Directory = _Current Directory +_Buffer = _Buffer +_Next Buffer = _Next Buffer +_Previous Buffer = _Previous Buffer +Swit_ch Buffer = Swit_ch Buffer +Toggle View _EOL = Toggle View _EOL +Toggle _Wrap Mode = Toggle _Wrap Mode +Toggle Show _Indentation Guides = Toggle Show _Indentation Guides +Toggle Use _Tabs = Toggle Use _Tabs +Toggle View White_space = Toggle View White_space +EOL Mode = EOL Mode +Encoding = Encoding +UTF-8 = UTF-8 +ASCII = ASCII +ISO-8859-1 = ISO-8859-1 +MacRoman = MacRoman +UTF-16 = UTF-16 +_Refresh Syntax Highlighting = _Refresh Syntax Highlighting +_View = _View +_Next View = _Next View +_Previous View = _Previous View +Split _Vertical = Split _Vertical +Split _Horizontal = Split _Horizontal +_Unsplit = _Unsplit +Unsplit _All = Unsplit _All +_Grow = _Grow +_Shrink = _Shrink +Le_xers = Le_xers +_Help = _Help +_Manual = _Manual +_LuaDoc = _LuaDoc +gtk-about = gtk-about +Error loading webpage: = Error loading webpage: +Load Session = Load Session +Save Session = Save Session +Unknown command: = Unknown command: % modules/textadept/mime_types.lua -% "Select Lexer" -MT_SELECT_LEXER "Select Lexer" - -% modules/textadept/editing.lua -% "Go To" -M_TEXTADEPT_EDITING_GOTO_TITLE "Go To" +Select Lexer = Select Lexer % modules/textadept/editing.lua -% "Line Number:" -M_TEXTADEPT_EDITING_GOTO_TEXT "Line Number:" +Go To = Go To +Line Number: = Line Number: % modules/textadept/run.lua -% "The file "%s" does not exist." -M_TEXTADEPT_RUN_FILE_DOES_NOT_EXIST "The file "%s" does not exist." +does not exist = does not exist % modules/textadept/snippets.lua -% "Lexer %s\nStyle %s (%d)" -M_TEXTADEPT_SNIPPETS_SHOW_STYLE "Lexer %s\nStyle %s (%d)" +Lexer = Lexer +Style = Style % modules/textadept/session.lua -% "Session Files Not Found" -M_SESSION_FILES_NOT_FOUND_TITLE "Session Files Not Found" - -% modules/textadept/session.lua -% "The following session files were not found" -M_SESSION_FILES_NOT_FOUND_TEXT "The following session files were not found" - -% modules/textadept/snapopen.lua -% "File Limit Exceeded" -M_SNAPOPEN_LIMIT_EXCEEDED_TITLE "File Limit Exceeded" +Session Files Not Found = Session Files Not Found +The following session files were not found = The following session files were not found % modules/textadept/snapopen.lua -% "%s files or more were found. Showing the first %s." -M_SNAPOPEN_LIMIT_EXCEEDED_TEXT "%s files or more were found. Showing the first %s." +File Limit Exceeded = File Limit Exceeded +files or more were found. Showing the first = files or more were found. Showing the first diff --git a/core/locale.lua b/core/locale.lua index 93bf1024..5b14a254 100644 --- a/core/locale.lua +++ b/core/locale.lua @@ -19,20 +19,23 @@ module('locale', package.seeall) -- Each message ID in `core/locale.conf` is accessible as a field in this -- module. -local escapes = { ['\\n'] = '\n', ['\\r'] = '\r', ['\\t'] = '\t' } +-- Contains all localizations for the current locale. +-- @class table +-- @name localizations +local localizations = {} local f = io.open(_USERHOME..'/locale.conf', 'rb') if not f then f = io.open(_HOME..'/core/locale.conf', 'rb') end if not f then error('"core/locale.conf" not found.') end for line in f:lines() do if not line:find('^%s*%%') then - local id, str = line:match('^%s*(%S+)%s+"(.+)"$') - if id and str then locale[id] = str:gsub('\\[nrt]', escapes) end + local id, str = line:match('^(.-)%s*=%s*(.+)$') + if id and str then localizations[id] = str end end end f:close() --- --- This module contains no functions. -function no_functions() end -no_functions = nil -- undefine +-- Localizes the given string. +-- @param id String to localize. +function localize(id) return localizations[id] or 'No Localization' end diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 839b70e8..e3b19e80 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize local events = _G.events --- @@ -141,9 +141,6 @@ events.connect('char_added', end end) --- local functions -local get_preceding_number - --- -- Goes to a matching brace position, selecting the text inside if specified. -- @param select If true, selects the text between matching braces. @@ -233,8 +230,8 @@ function goto_line(line) local buffer = buffer if not line then line = gui.dialog('standard-inputbox', - '--title', locale.M_TEXTADEPT_EDITING_GOTO_TITLE, - '--text', locale.M_TEXTADEPT_EDITING_GOTO_TEXT, + '--title', L('Go To'), + '--text', L('Line Number:'), '--no-newline') line = tonumber(line:match('%-?%d+$')) if not line or line < 0 then return end @@ -323,6 +320,22 @@ function join_lines() buffer:lines_join() end +-- Returns the number to the left of the caret. +-- This is used for the enclose function. +-- @see enclose +local function get_preceding_number() + local buffer = buffer + local caret = buffer.current_pos + local char = buffer.char_at[caret - 1] + local txt = '' + while tonumber(string.char(char)) do + txt = txt..string.char(char) + caret = caret - 1 + char = buffer.char_at[caret - 1] + end + return tonumber(txt) or 1, #txt +end + --- -- Encloses text in an enclosure set. -- If text is selected, it is enclosed. Otherwise, the previous word is diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 80f24a4e..484d0bb6 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize local events = _G.events local find = gui.find @@ -75,7 +75,7 @@ local function find_(text, next, flags, nowrap, wrapped) else -- find in files local utf8_dir = gui.dialog('fileselect', - '--title', locale.FIND_IN_FILES_TITLE, + '--title', L('Find in Files'), '--select-only-directories', '--with-directory', (buffer.filename or ''):match('^.+[/\\]') or '', @@ -116,12 +116,10 @@ local function find_(text, next, flags, nowrap, wrapped) end local dir = utf8_dir:iconv(_CHARSET, 'UTF-8') search_dir(dir) - if #matches == 1 then matches[2] = locale.FIND_NO_RESULTS end + if #matches == 1 then matches[2] = L('No results found') end matches[#matches + 1] = '' - if buffer._type ~= locale.FIND_FILES_FOUND_BUFFER then - previous_view = view - end - gui._print(locale.FIND_FILES_FOUND_BUFFER, table.concat(matches, '\n')) + if buffer._type ~= L('[Files Found Buffer]') then previous_view = view end + gui._print(L('[Files Found Buffer]'), table.concat(matches, '\n')) end return end @@ -133,10 +131,10 @@ local function find_(text, next, flags, nowrap, wrapped) else buffer:goto_pos(buffer.length) end - gui.statusbar_text = locale.FIND_SEARCH_WRAPPED + gui.statusbar_text = L('Search wrapped') result = find_(text, next, flags, true, true) if result == -1 then - gui.statusbar_text = locale.FIND_NO_RESULTS + gui.statusbar_text = L('No results found') buffer:line_scroll(0, first_visible_line) buffer:goto_pos(anchor) end @@ -219,8 +217,8 @@ local function replace(rtext) local ret, val = pcall(loadstring('return '..code)) if not ret then gui.dialog('ok-msgbox', - '--title', locale.FIND_ERROR_DIALOG_TITLE, - '--text', locale.FIND_ERROR_DIALOG_TEXT, + '--title', L('Error'), + '--text', L('An error occured:'), '--informative-text', val:gsub('"', '\\"'), '--no-cancel') error() @@ -269,7 +267,7 @@ local function replace_all(ftext, rtext, flags) local pos = find_(ftext, true, flags, true) while pos ~= -1 and pos < buffer:position_from_line( - buffer:marker_line_from_handle(end_marker)) do + buffer:marker_line_from_handle(end_marker)) do replace(rtext) count = count + 1 pos = find_(ftext, true, flags, true) @@ -281,8 +279,8 @@ local function replace_all(ftext, rtext, flags) buffer:set_sel(anchor, current_pos) buffer:marker_delete_handle(end_marker) end - gui.statusbar_text = string.format(locale.FIND_REPLACEMENTS_MADE, - tostring(count)) + gui.statusbar_text = string.format("%d %s", tostring(count), + L('replacement(s) made')) buffer:end_undo_action() end events.connect('replace_all', replace_all) @@ -292,7 +290,7 @@ events.connect('replace_all', replace_all) -- @param pos The position of the caret. -- @param line_num The line double-clicked. local function goto_file(pos, line_num) - if buffer._type == locale.FIND_FILES_FOUND_BUFFER then + if buffer._type == L('[Files Found Buffer]') then line = buffer:get_line(line_num) local file, file_line_num = line:match('^(.+):(%d+):.+$') if file and file_line_num then @@ -305,7 +303,7 @@ local function goto_file(pos, line_num) else local clicked_view = view if previous_view then previous_view:focus() end - if buffer._type == locale.FIND_FILES_FOUND_BUFFER then + if buffer._type == L('[Files Found Buffer]') then -- there are at least two find in files views; find one of those views -- that the file was not selected from and focus it for _, v in ipairs(_VIEWS) do @@ -329,7 +327,7 @@ events.connect('double_click', goto_file) function find.goto_file_in_list(next) local orig_view = view for _, buffer in ipairs(_BUFFERS) do - if buffer._type == locale.FIND_FILES_FOUND_BUFFER then + if buffer._type == L('[Files Found Buffer]') then for _, view in ipairs(_VIEWS) do if view.doc_pointer == buffer.doc_pointer then view:focus() diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua index 9a38c709..a5e93225 100644 --- a/modules/textadept/keys.lua +++ b/modules/textadept/keys.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize local events = _G.events --- @@ -553,7 +553,7 @@ local function run_key_command(lexer, scope) if type(key) ~= 'table' then return INVALID end end if #key == 0 and next(key) then - gui.statusbar_text = locale.KEYCHAIN..table.concat(keychain, ' ') + gui.statusbar_text = L('Keychain:')..' '..table.concat(keychain, ' ') return CHAIN end @@ -567,7 +567,7 @@ local function run_key_command(lexer, scope) end if type(f) ~= 'function' then - error(locale.KEYS_UNKNOWN_COMMAND..tostring(f)) + error(L('Unknown command:')..tostring(f)) end return f(unpack(args)) == false and PROPAGATE or HALT end @@ -629,8 +629,8 @@ local function keypress(code, shift, control, alt) -- Clear the key sequence, but keep any status messages from the key -- command itself. keychain = {} - if not (gui.statusbar_text == locale.INVALID or - gui.statusbar_text:find('^'..locale.KEYCHAIN)) then + if not (gui.statusbar_text == L('Invalid sequence') or + gui.statusbar_text:find('^'..L('Keychain:'))) then gui.statusbar_text = '' end end @@ -641,7 +641,7 @@ local function keypress(code, shift, control, alt) local size = #keychain - 1 clear_key_sequence() if not success and size > 0 then -- INVALID keychain sequence - gui.statusbar_text = locale.KEYS_INVALID + gui.statusbar_text = L('Invalid sequence') return true end -- PROPAGATE otherwise. diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua index f014d8c2..658b72b4 100644 --- a/modules/textadept/menu.lua +++ b/modules/textadept/menu.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize local events = _G.events --- @@ -132,157 +132,157 @@ local ID = { local menubar = { gtkmenu { - title = l.MENU_FILE_TITLE, - { l.MENU_FILE_NEW, ID.NEW }, - { l.MENU_FILE_OPEN, ID.OPEN }, - { l.MENU_FILE_RELOAD, ID.RELOAD }, - { l.MENU_FILE_SAVE, ID.SAVE }, - { l.MENU_FILE_SAVEAS, ID.SAVEAS }, + title = L('_File'), + { L('gtk-new'), ID.NEW }, + { L('gtk-open'), ID.OPEN }, + { L('_Reload'), ID.RELOAD }, + { L('gtk-save'), ID.SAVE }, + { L('gtk-save-as'), ID.SAVEAS }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_FILE_CLOSE, ID.CLOSE }, - { l.MENU_FILE_CLOSE_ALL, ID.CLOSE_ALL }, + { L('gtk-close'), ID.CLOSE }, + { L('Close A_ll'), ID.CLOSE_ALL }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_FILE_LOAD_SESSION, ID.LOAD_SESSION }, - { l.MENU_FILE_SAVE_SESSION, ID.SAVE_SESSION }, + { L('Loa_d Session...'), ID.LOAD_SESSION }, + { L('Sa_ve Session...'), ID.SAVE_SESSION }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_FILE_QUIT, ID.QUIT }, + { L('gtk-quit'), ID.QUIT }, }, gtkmenu { - title = l.MENU_EDIT_TITLE, - { l.MENU_EDIT_UNDO, ID.UNDO }, - { l.MENU_EDIT_REDO, ID.REDO }, + title = L('_Edit'), + { L('gtk-undo'), ID.UNDO }, + { L('gtk-redo'), ID.REDO }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_EDIT_CUT, ID.CUT }, - { l.MENU_EDIT_COPY, ID.COPY }, - { l.MENU_EDIT_PASTE, ID.PASTE }, - { l.MENU_EDIT_DELETE, ID.DELETE }, - { l.MENU_EDIT_SELECT_ALL, ID.SELECT_ALL }, + { L('gtk-cut'), ID.CUT }, + { L('gtk-copy'), ID.COPY }, + { L('gtk-paste'), ID.PASTE }, + { L('gtk-delete'), ID.DELETE }, + { L('gtk-select-all'), ID.SELECT_ALL }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_EDIT_MATCH_BRACE, ID.MATCH_BRACE }, - { l.MENU_EDIT_SELECT_TO_BRACE, ID.SELECT_TO_BRACE }, - { l.MENU_EDIT_COMPLETE_WORD, ID.COMPLETE_WORD }, - { l.MENU_EDIT_DELETE_WORD, ID.DELETE_WORD }, - { l.MENU_EDIT_TRANSPOSE_CHARACTERS, ID.TRANSPOSE_CHARACTERS }, - { l.MENU_EDIT_JOIN_LINES, ID.JOIN_LINES }, - { l.MENU_EDIT_CONVERT_INDENTATION, ID.CONVERT_INDENTATION }, - { title = l.MENU_EDIT_SEL_TITLE, - { title = l.MENU_EDIT_SEL_ENC_TITLE, - { l.MENU_EDIT_SEL_ENC_HTML_TAGS, ID.ENCLOSE_IN_HTML_TAGS }, - { l.MENU_EDIT_SEL_ENC_HTML_SINGLE_TAG, ID.ENCLOSE_IN_HTML_SINGLE_TAG }, - { l.MENU_EDIT_SEL_ENC_DOUBLE_QUOTES, ID.ENCLOSE_IN_DOUBLE_QUOTES }, - { l.MENU_EDIT_SEL_ENC_SINGLE_QUOTES, ID.ENCLOSE_IN_SINGLE_QUOTES }, - { l.MENU_EDIT_SEL_ENC_PARENTHESES, ID.ENCLOSE_IN_PARENTHESES }, - { l.MENU_EDIT_SEL_ENC_BRACKETS, ID.ENCLOSE_IN_BRACKETS }, - { l.MENU_EDIT_SEL_ENC_BRACES, ID.ENCLOSE_IN_BRACES }, - { l.MENU_EDIT_SEL_ENC_CHAR_SEQ, ID.ENCLOSE_IN_CHARACTER_SEQUENCE }, + { L('Match _Brace'), ID.MATCH_BRACE }, + { L('Select t_o Brace'), ID.SELECT_TO_BRACE }, + { L('Complete _Word'), ID.COMPLETE_WORD }, + { L('De_lete Word'), ID.DELETE_WORD }, + { L('Tran_spose Characters'), ID.TRANSPOSE_CHARACTERS }, + { L('_Join Lines'), ID.JOIN_LINES }, + { L('Convert _Indentation'), ID.CONVERT_INDENTATION }, + { title = L('S_election'), + { title = L('_Enclose in...'), + { L('_HTML Tags'), ID.ENCLOSE_IN_HTML_TAGS }, + { L('HTML Single _Tag'), ID.ENCLOSE_IN_HTML_SINGLE_TAG }, + { L('_Double Quotes'), ID.ENCLOSE_IN_DOUBLE_QUOTES }, + { L('_Single Quotes'), ID.ENCLOSE_IN_SINGLE_QUOTES }, + { L('_Parentheses'), ID.ENCLOSE_IN_PARENTHESES }, + { L('_Brackets'), ID.ENCLOSE_IN_BRACKETS }, + { L('B_races'), ID.ENCLOSE_IN_BRACES }, + { L('_Character Sequence'), ID.ENCLOSE_IN_CHARACTER_SEQUENCE }, }, - { l.MENU_EDIT_SEL_GROW, ID.GROW_SELECTION }, + { L('_Grow'), ID.GROW_SELECTION }, }, - { title = l.MENU_EDIT_SEL_IN_TITLE, - { l.MENU_EDIT_SEL_IN_HTML_TAG, ID.SELECT_IN_HTML_TAG }, - { l.MENU_EDIT_SEL_IN_DOUBLE_QUOTE, ID.SELECT_IN_DOUBLE_QUOTE }, - { l.MENU_EDIT_SEL_IN_SINGLE_QUOTE, ID.SELECT_IN_SINGLE_QUOTE }, - { l.MENU_EDIT_SEL_IN_PARENTHESIS, ID.SELECT_IN_PARENTHESIS }, - { l.MENU_EDIT_SEL_IN_BRACKET, ID.SELECT_IN_BRACKET }, - { l.MENU_EDIT_SEL_IN_BRACE, ID.SELECT_IN_BRACE }, - { l.MENU_EDIT_SEL_IN_WORD, ID.SELECT_IN_WORD }, - { l.MENU_EDIT_SEL_IN_LINE, ID.SELECT_IN_LINE }, - { l.MENU_EDIT_SEL_IN_PARAGRAPH, ID.SELECT_IN_PARAGRAPH }, - { l.MENU_EDIT_SEL_IN_INDENTED_BLOCK, ID.SELECT_IN_INDENTED_BLOCK }, - { l.MENU_EDIT_SEL_IN_SCOPE, ID.SELECT_IN_SCOPE }, + { title = L('Select i_n...'), + { L('_HTML Tag'), ID.SELECT_IN_HTML_TAG }, + { L('_Double Quote'), ID.SELECT_IN_DOUBLE_QUOTE }, + { L('_Single Quote'), ID.SELECT_IN_SINGLE_QUOTE }, + { L('_Parenthesis'), ID.SELECT_IN_PARENTHESIS }, + { L('_Bracket'), ID.SELECT_IN_BRACKET }, + { L('B_race'), ID.SELECT_IN_BRACE }, + { L('_Word'), ID.SELECT_IN_WORD }, + { L('_Line'), ID.SELECT_IN_LINE }, + { L('Para_graph'), ID.SELECT_IN_PARAGRAPH }, + { L('_Indented Block'), ID.SELECT_IN_INDENTED_BLOCK }, + { L('S_cope'), ID.SELECT_IN_SCOPE }, }, }, gtkmenu { - title = l.MENU_TOOLS_TITLE, - { title = l.MENU_TOOLS_SEARCH_TITLE, - { l.MENU_TOOLS_SEARCH_FIND, ID.FIND }, - { l.MENU_TOOLS_SEARCH_FIND_NEXT, ID.FIND_NEXT }, - { l.MENU_TOOLS_SEARCH_FIND_PREV, ID.FIND_PREV }, - { l.MENU_TOOLS_SEARCH_FIND_AND_REPLACE, ID.FIND_AND_REPLACE }, - { l.MENU_TOOLS_SEARCH_REPLACE, ID.REPLACE }, - { l.MENU_TOOLS_SEARCH_REPLACE_ALL, ID.REPLACE_ALL }, - { l.MENU_TOOLS_SEARCH_FIND_INCREMENTAL, ID.FIND_INCREMENTAL }, + title = L('_Tools'), + { title = L('_Find'), + { L('gtk-find'), ID.FIND }, + { L('Find _Next'), ID.FIND_NEXT }, + { L('Find _Previous'), ID.FIND_PREV }, + { L('gtk-find-and-replace'), ID.FIND_AND_REPLACE }, + { L('Replace'), ID.REPLACE }, + { L('Replace _All'), ID.REPLACE_ALL }, + { L('Find _Incremental'), ID.FIND_INCREMENTAL }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_TOOLS_SEARCH_FIND_IN_FILES, ID.FIND_IN_FILES }, - { l.MENU_TOOLS_SEARCH_GOTO_NEXT_FILE_FOUND, ID.GOTO_NEXT_FILE_FOUND }, - { l.MENU_TOOLS_SEARCH_GOTO_PREV_FILE_FOUND, ID.GOTO_PREV_FILE_FOUND }, + { L('Find in Fi_les'), ID.FIND_IN_FILES }, + { L('Goto Next File Found'), ID.GOTO_NEXT_FILE_FOUND }, + { L('Goto Previous File Found'), ID.GOTO_PREV_FILE_FOUND }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_TOOLS_SEARCH_GOTO_LINE, ID.GOTO_LINE }, + { L('gtk-jump-to'), ID.GOTO_LINE }, }, - { l.MENU_TOOLS_FOCUS_COMMAND_ENTRY, ID.FOCUS_COMMAND_ENTRY }, + { L('Command _Entry'), ID.FOCUS_COMMAND_ENTRY }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_TOOLS_RUN, ID.RUN }, - { l.MENU_TOOLS_COMPILE, ID.COMPILE }, + { L('_Run'), ID.RUN }, + { L('_Compile'), ID.COMPILE }, { SEPARATOR, ID.SEPARATOR }, - { title = l.MENU_TOOLS_SNIPPETS_TITLE, - { l.MENU_TOOLS_SNIPPETS_INSERT, ID.INSERT_SNIPPET }, - { l.MENU_TOOLS_SNIPPETS_PREV_PLACE, ID.PREVIOUS_SNIPPET_PLACEHOLDER }, - { l.MENU_TOOLS_SNIPPETS_CANCEL, ID.CANCEL_SNIPPET }, - { l.MENU_TOOLS_SNIPPETS_LIST, ID.LIST_SNIPPETS }, - { l.MENU_TOOLS_SNIPPETS_SHOW_SCOPE, ID.SHOW_SCOPE }, + { title = L('_Snippets'), + { L('_Insert'), ID.INSERT_SNIPPET }, + { L('_Previous Placeholder'), ID.PREVIOUS_SNIPPET_PLACEHOLDER }, + { L('_Cancel'), ID.CANCEL_SNIPPET }, + { L('_List'), ID.LIST_SNIPPETS }, + { L('_Show Scope'), ID.SHOW_SCOPE }, }, - { title = l.MENU_TOOLS_BM_TITLE, - { l.MENU_TOOLS_BM_TOGGLE, ID.TOGGLE_BOOKMARK }, - { l.MENU_TOOLS_BM_CLEAR_ALL, ID.CLEAR_BOOKMARKS }, - { l.MENU_TOOLS_BM_NEXT, ID.GOTO_NEXT_BOOKMARK }, - { l.MENU_TOOLS_BM_PREV, ID.GOTO_PREV_BOOKMARK }, + { title = L('_Bookmark'), + { L('_Toggle on Current Line'), ID.TOGGLE_BOOKMARK }, + { L('_Clear All'), ID.CLEAR_BOOKMARKS }, + { L('_Next'), ID.GOTO_NEXT_BOOKMARK }, + { L('_Previous'), ID.GOTO_PREV_BOOKMARK }, }, - { title = l.MENU_TOOLS_SNAPOPEN_TITLE, - { l.MENU_TOOLS_SNAPOPEN_USERHOME, ID.SNAPOPEN_USERHOME }, - { l.MENU_TOOLS_SNAPOPEN_HOME, ID.SNAPOPEN_HOME }, - { l.MENU_TOOLS_SNAPOPEN_CURRENTDIR, ID.SNAPOPEN_CURRENTDIR }, + { title = L('Snap_open'), + { L('_User Home'), ID.SNAPOPEN_USERHOME }, + { L('_Textadept Home'), ID.SNAPOPEN_HOME }, + { L('_Current Directory'), ID.SNAPOPEN_CURRENTDIR }, }, }, gtkmenu { - title = l.MENU_BUF_TITLE, - { l.MENU_BUF_NEXT, ID.NEXT_BUFFER }, - { l.MENU_BUF_PREV, ID.PREV_BUFFER }, - { l.MENU_BUF_SWITCH, ID.SWITCH_BUFFER }, + title = L('_Buffer'), + { L('_Next Buffer'), ID.NEXT_BUFFER }, + { L('_Previous Buffer'), ID.PREV_BUFFER }, + { L('Swit_ch Buffer'), ID.SWITCH_BUFFER }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_BUF_TOGGLE_VIEW_EOL, ID.TOGGLE_VIEW_EOL }, - { l.MENU_BUF_TOGGLE_WRAP, ID.TOGGLE_WRAP_MODE }, - { l.MENU_BUF_TOGGLE_INDENT_GUIDES, ID.TOGGLE_SHOW_INDENT_GUIDES }, - { l.MENU_BUF_TOGGLE_TABS, ID.TOGGLE_USE_TABS }, - { l.MENU_BUF_TOGGLE_VIEW_WHITESPACE, ID.TOGGLE_VIEW_WHITESPACE }, + { L('Toggle View _EOL'), ID.TOGGLE_VIEW_EOL }, + { L('Toggle _Wrap Mode'), ID.TOGGLE_WRAP_MODE }, + { L('Toggle Show _Indentation Guides'), ID.TOGGLE_SHOW_INDENT_GUIDES }, + { L('Toggle Use _Tabs'), ID.TOGGLE_USE_TABS }, + { L('Toggle View White_space'), ID.TOGGLE_VIEW_WHITESPACE }, { SEPARATOR, ID.SEPARATOR }, - { title = l.MENU_BUF_EOL_MODE_TITLE, - { l.MENU_BUF_EOL_MODE_CRLF, ID.EOL_MODE_CRLF }, - { l.MENU_BUF_EOL_MODE_CR, ID.EOL_MODE_CR }, - { l.MENU_BUF_EOL_MODE_LF, ID.EOL_MODE_LF }, + { title = L('EOL Mode'), + { L('CRLF'), ID.EOL_MODE_CRLF }, + { L('CR'), ID.EOL_MODE_CR }, + { L('LF'), ID.EOL_MODE_LF }, }, - { title = l.MENU_BUF_ENCODING_TITLE, - { l.MENU_BUF_ENCODING_UTF8, ID.ENCODING_UTF8 }, - { l.MENU_BUF_ENCODING_ASCII, ID.ENCODING_ASCII }, - { l.MENU_BUF_ENCODING_ISO88591, ID.ENCODING_ISO88591 }, - { l.MENU_BUF_ENCODING_MACROMAN, ID.ENCODING_MACROMAN }, - { l.MENU_BUF_ENCODING_UTF16, ID.ENCODING_UTF16 }, + { title = L('Encoding'), + { L('UTF-8'), ID.ENCODING_UTF8 }, + { L('ASCII'), ID.ENCODING_ASCII }, + { L('ISO-8859-1'), ID.ENCODING_ISO88591 }, + { L('MacRoman'), ID.ENCODING_MACROMAN }, + { L('UTF-16'), ID.ENCODING_UTF16 }, }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_BUF_REFRESH, ID.REFRESH_SYNTAX_HIGHLIGHTING }, + { L('_Refresh Syntax Highlighting'), ID.REFRESH_SYNTAX_HIGHLIGHTING }, }, gtkmenu { - title = l.MENU_VIEW_TITLE, - { l.MENU_VIEW_NEXT, ID.NEXT_VIEW }, - { l.MENU_VIEW_PREV, ID.PREV_VIEW }, + title = L('_View'), + { L('_Next View'), ID.NEXT_VIEW }, + { L('_Previous View'), ID.PREV_VIEW }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_VIEW_SPLIT_VERTICAL, ID.SPLIT_VIEW_VERTICAL }, - { l.MENU_VIEW_SPLIT_HORIZONTAL, ID.SPLIT_VIEW_HORIZONTAL }, - { l.MENU_VIEW_UNSPLIT, ID.UNSPLIT_VIEW }, - { l.MENU_VIEW_UNSPLIT_ALL, ID.UNSPLIT_ALL_VIEWS }, + { L('Split _Vertical'), ID.SPLIT_VIEW_VERTICAL }, + { L('Split _Horizontal'), ID.SPLIT_VIEW_HORIZONTAL }, + { L('_Unsplit'), ID.UNSPLIT_VIEW }, + { L('Unsplit _All'), ID.UNSPLIT_ALL_VIEWS }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_VIEW_GROW, ID.GROW_VIEW }, - { l.MENU_VIEW_SHRINK, ID.SHRINK_VIEW }, + { L('_Grow'), ID.GROW_VIEW }, + { L('_Shrink'), ID.SHRINK_VIEW }, }, -- Lexer menu inserted here gtkmenu { - title = l.MENU_HELP_TITLE, - { l.MENU_HELP_MANUAL, ID.MANUAL }, - { l.MENU_HELP_LUADOC, ID.LUADOC }, + title = L('_Help'), + { L('_Manual'), ID.MANUAL }, + { L('_LuaDoc'), ID.LUADOC }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_HELP_ABOUT, ID.ABOUT }, + { L('gtk-about'), ID.ABOUT }, }, } -local lexer_menu = { title = l.MENU_LEX_TITLE } +local lexer_menu = { title = L('Le_xers') } for _, lexer in ipairs(_m.textadept.mime_types.lexers) do lexer = lexer:gsub('_', '__') -- no accelerators lexer_menu[#lexer_menu + 1] = { lexer, ID.LEXER_START + #lexer_menu } @@ -325,10 +325,10 @@ local function open_webpage(url) if WIN32 then cmd = string.format('start "" "%s"', url) local p = io.popen(cmd) - if not p then error(l.MENU_BROWSER_ERROR..url) end + if not p then error(L('Error loading webpage:')..url) end else cmd = string.format(MAC and 'open "file://%s"' or 'xdg-open "%s" &', url) - if os.execute(cmd) ~= 0 then error(l.MENU_BROWSER_ERROR..url) end + if os.execute(cmd) ~= 0 then error(L('Error loading webpage:')..url) end end end @@ -345,7 +345,7 @@ local actions = { function() local session_file = _SESSIONFILE or '' local utf8_filename = gui.dialog('fileselect', - '--title', l.MENU_LOAD_SESSION_TITLE, + '--title', L('Load Session'), '--with-directory', session_file:match('.+[/\\]') or '', '--with-file', @@ -360,7 +360,7 @@ local actions = { function() local session_file = _SESSIONFILE or '' local utf8_filename = gui.dialog('filesave', - '--title', l.MENU_SAVE_SESSION_TITLE, + '--title', L('Save Session'), '--with-directory', session_file:match('.+[/\\]') or '', '--with-file', @@ -515,20 +515,20 @@ events.connect('menu_clicked', local ret, retval = pcall(f, unpack(args)) if not ret then error(retval) end else - error(l.MENU_UNKNOWN_COMMAND..tostring(func)) + error(L('Unknown command:')..' '..tostring(func)) end end end) -- Right-click context menu. gui.context_menu = gtkmenu { - { l.MENU_EDIT_UNDO, ID.UNDO }, - { l.MENU_EDIT_REDO, ID.REDO }, + { L('gtk-undo'), ID.UNDO }, + { L('gtk-redo'), ID.REDO }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_EDIT_CUT, ID.CUT }, - { l.MENU_EDIT_COPY, ID.COPY }, - { l.MENU_EDIT_PASTE, ID.PASTE }, - { l.MENU_EDIT_DELETE, ID.DELETE }, + { L('gtk-cut'), ID.CUT }, + { L('gtk-copy'), ID.COPY }, + { L('gtk-paste'), ID.PASTE }, + { L('gtk-delete'), ID.DELETE }, { SEPARATOR, ID.SEPARATOR }, - { l.MENU_EDIT_SELECT_ALL, ID.SELECT_ALL } + { L('gtk-select-all'), ID.SELECT_ALL } } diff --git a/modules/textadept/mime_types.lua b/modules/textadept/mime_types.lua index 4908708f..372a305a 100644 --- a/modules/textadept/mime_types.lua +++ b/modules/textadept/mime_types.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize local events = _G.events --- @@ -283,7 +283,7 @@ events.connect('reset_after', -- buffer. function select_lexer() local out = gui.dialog('filteredlist', - '--title', locale.MT_SELECT_LEXER, + '--title', L('Select Lexer'), '--button1', 'gtk-ok', '--button2', 'gtk-cancel', '--no-newline', diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua index 78b1fbdb..772214cb 100644..100755 --- a/modules/textadept/run.lua +++ b/modules/textadept/run.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize --- -- Module for running/executing source files. @@ -107,7 +107,7 @@ error_detail = {} -- @see error_detail function goto_error(pos, line_num) local type = buffer._type - if type == locale.MESSAGE_BUFFER or type == locale.ERROR_BUFFER then + if type == L('[Message Buffer]') or type == L('[Error Buffer]') then line = buffer:get_line(line_num) for _, error_detail in pairs(error_detail) do local captures = { line:match(error_detail.pattern) } @@ -121,8 +121,7 @@ function goto_error(pos, line_num) local msg = captures[error_detail.message] if msg then buffer:call_tip_show(buffer.current_pos, msg) end else - error(string.format( - locale.M_TEXTADEPT_RUN_FILE_DOES_NOT_EXIST, utf8_filename)) + error(string.format('"%s" %s', L('does not exist'), utf8_filename)) end break end diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index 59e3009a..c8fc1d90 100644..100755 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize --- -- Session support for the textadept module. @@ -88,8 +88,8 @@ function load(filename) _SESSIONFILE = filename or DEFAULT_SESSION if #not_found > 0 then gui.dialog('msgbox', - '--title', locale.M_SESSION_FILES_NOT_FOUND_TITLE, - '--text', locale.M_SESSION_FILES_NOT_FOUND_TEXT, + '--title', L('Session Files Not Found'), + '--text', L('The following session files were not found'), '--informative-text', string.format('%s', table.concat(not_found, '\n'))) end diff --git a/modules/textadept/snapopen.lua b/modules/textadept/snapopen.lua index 62320835..f472b744 100644..100755 --- a/modules/textadept/snapopen.lua +++ b/modules/textadept/snapopen.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-local locale = _G.locale
+local L = _G.locale.localize
---
-- Snapopen for the textadept module.
@@ -108,12 +108,14 @@ function open(paths, filter, exclusive, depth) for _, path in ipairs(paths) do add_directory(path, list, 1, filter) end
if #list >= MAX then
gui.dialog('ok-msgbox',
- '--title', locale.M_SNAPOPEN_LIMIT_EXCEEDED_TITLE,
+ '--title', L('File Limit Exceeded'),
'--informative-text',
- string.format(locale.M_SNAPOPEN_LIMIT_EXCEEDED_TEXT, MAX, MAX))
+ string.format('%d %s %d', MAX,
+ L('files or more were found. Showing the first'),
+ MAX))
end
local out = gui.dialog('filteredlist',
- '--title', locale.IO_OPEN_TITLE,
+ '--title', L('Open'),
'--button1', 'gtk-ok',
'--button2', 'gtk-cancel',
'--no-newline',
diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua index 0c1b5e8b..6ea39563 100644..100755 --- a/modules/textadept/snippets.lua +++ b/modules/textadept/snippets.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize --- -- Provides Lua-style snippets for Textadept. @@ -462,7 +462,7 @@ function _show_style() local lexer = buffer:get_lexer() local style_num = buffer.style_at[buffer.current_pos] local style = buffer:get_style_name(style_num) - local text = string.format(locale.M_TEXTADEPT_SNIPPETS_SHOW_STYLE, lexer, + local text = string.format("%s %s\n%s %s (%d)", L('Lexer'), lexer, L('Style'), style, style_num) buffer:call_tip_show(buffer.current_pos, text) end |