From c15e9a9cf36da02cb883eb14fd3a4ee23548f675 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sat, 3 Jan 2009 22:50:12 -0500 Subject: Added localization support. All Textadept messages are in core/locale.lua which provides the new 'textadept.locale' module. --- core/ext/find.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'core/ext/find.lua') diff --git a/core/ext/find.lua b/core/ext/find.lua index ca3c28f0..94371689 100644 --- a/core/ext/find.lua +++ b/core/ext/find.lua @@ -25,7 +25,7 @@ local escapes = { -- for displaying useful statusbar information. This flag is used and set -- internally, and should not be set otherwise. function find.find(text, next, flags, nowrap, wrapped) - local buffer = buffer + local buffer, textadept = buffer, textadept local increment, result text = text:gsub('\\[abfnrtv\\]', escapes) find.captures = nil @@ -68,10 +68,10 @@ function find.find(text, next, flags, nowrap, wrapped) else buffer:goto_pos(buffer.length) end - textadept.statusbar_text = 'Search wrapped' + textadept.statusbar_text = textadept.locale.FIND_SEARCH_WRAPPED result = find.find(text, next, flags, true, true) if not result then - textadept.statusbar_text = 'No results found' + textadept.statusbar_text = textadept.locale.FIND_NO_RESULTS buffer:goto_pos(anchor) end return result @@ -103,11 +103,12 @@ function find.replace(rtext) end local ret, rtext = pcall( rtext.gsub, rtext, '%%(%b())', function(code) + local locale = textadept.locale local ret, val = pcall( loadstring('return '..code) ) if not ret then cocoa_dialog( 'msgbox', { - title = 'Error', - text = 'An error occured:', + title = locale.FIND_ERROR_DIALOG_TITLE, + text = locale.FIND_ERROR_DIALOG_TEXT, ['informative-text'] = val:gsub('"', '\\"') } ) error() @@ -134,11 +135,13 @@ end -- @param flags The number mask identical to the one in 'find'. -- @see find.find function find.replace_all(ftext, rtext, flags) + local textadept = textadept buffer:goto_pos(0) local count = 0 while( find.find(ftext, true, flags, true) ) do find.replace(rtext) count = count + 1 end - textadept.statusbar_text = tostring(count)..' replacement(s) made' + textadept.statusbar_text = tostring(count)..' '.. + textadept.locale.FIND_REPLACEMENTS_MADE end -- cgit v1.2.3