Skip to content

Commit

Permalink
Fixed showing of not translated messages that require pluralization.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkulchenko committed Apr 17, 2015
1 parent 6596d3a commit 6c20164
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ do
if ide.config.language then
LoadLuaFileExt(ide.config.messages, "cfg"..sep.."i18n"..sep..ide.config.language..".lua")
end
-- always load 'en' as it's requires as a fallback for pluralization
if ide.config.language ~= 'en' then
LoadLuaFileExt(ide.config.messages, "cfg"..sep.."i18n"..sep.."en.lua")
end
end

loadPackages()
Expand Down
13 changes: 9 additions & 4 deletions src/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,17 @@ function RequestAttention()
end
end

local messages, lang, counter
function TR(msg, count)
lang = lang or ide.config.language
messages = messages or ide.config.messages
counter = counter or (messages[lang] and messages[lang][0])
local messages = ide.config.messages
local lang = ide.config.language
local counter = messages[lang] and messages[lang][0]
local message = messages[lang] and messages[lang][msg]
-- if there is count and no corresponding message, then
-- get the message from the (default) english language,
-- otherwise the message is not going to be pluralized properly
if count and not message then
message, counter = messages.en[msg], messages.en[0]
end
return count and counter and message and type(message) == 'table'
and message[counter(count)] or message or msg
end
Expand Down

0 comments on commit 6c20164

Please sign in to comment.