Skip to content

Commit

Permalink
Just use one locale namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
nebularg committed Jul 21, 2018
1 parent 193e7fc commit dc247c5
Show file tree
Hide file tree
Showing 29 changed files with 4,096 additions and 5,019 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Locales/Strings-enUS.lua
Libs/*
2 changes: 1 addition & 1 deletion Code/CombatEvents.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _, ns = ...
local Parrot = ns.addon
local module = Parrot:NewModule("CombatEvents", "AceEvent-3.0", "AceTimer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_CombatEvents")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local LibSharedMedia = LibStub("LibSharedMedia-3.0")

Expand Down
2 changes: 1 addition & 1 deletion Code/Display.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _, ns = ...
local Parrot = ns.addon
local module = Parrot:NewModule("Display")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_Display")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local Parrot_AnimationStyles
local Parrot_Suppressions
Expand Down
2 changes: 1 addition & 1 deletion Code/Parrot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ function Parrot:OnOptionsCreate()
gameText = {
type = "toggle",
name = L["Control game options"],
desc = L.controlGameOptionsDesc,
desc = L["Whether Parrot should control the default interface's options below.\nThese settings always override manual changes to the default interface options."],
descStyle = "inline",
set = function(info, value)
db[info[#info]] = value
Expand Down
2 changes: 1 addition & 1 deletion Code/ScrollAreas.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _, ns = ...
local Parrot = ns.addon
local module = Parrot:NewModule("ScrollAreas", "AceTimer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_ScrollAreas")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local Parrot_AnimationStyles = Parrot:GetModule("AnimationStyles")

Expand Down
2 changes: 1 addition & 1 deletion Code/Suppressions.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _, ns = ...
local Parrot = ns.addon
local module = Parrot:NewModule("Suppressions")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_Suppressions")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local string_find = _G.string.find
local pcall = _G.pcall
Expand Down
2 changes: 1 addition & 1 deletion Code/Triggers.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _, ns = ...
local Parrot = ns.addon
local module = Parrot:NewModule("Triggers", "AceEvent-3.0", "AceTimer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_Triggers")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local Parrot_TriggerConditions

Expand Down
2 changes: 1 addition & 1 deletion Data/AnimationStyles.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local _, ns = ...
local Parrot = ns.addon
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_AnimationStyles")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local math_max, math_min = math.max, math.min

Expand Down
16 changes: 8 additions & 8 deletions Data/Auras.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local _, ns = ...
local Parrot = ns.addon
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_Auras")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local newList, newDict = Parrot.newList, Parrot.newDict

Expand Down Expand Up @@ -595,7 +595,7 @@ Parrot:RegisterPrimaryTriggerCondition {
name = L["Spell"],
desc = L["Buff name or spell id"],
type = 'string',
usage = "<Buff name or spell id>",
usage = L["<Buff name or spell id>"],
save = saveSpell,
parse = parseSpell,
},
Expand Down Expand Up @@ -646,7 +646,7 @@ Parrot:RegisterPrimaryTriggerCondition {
name = L["Spell"],
desc = L["Buff name or spell id"],
type = 'string',
usage = "<Buff name or spell id>",
usage = L["<Buff name or spell id>"],
save = saveSpell,
parse = parseSpell,
},
Expand Down Expand Up @@ -708,7 +708,7 @@ Parrot:RegisterPrimaryTriggerCondition {
name = L["Spell"],
desc = L["Buff name or spell id"],
type = 'string',
usage = "<Buff name or spell id>",
usage = L["<Buff name or spell id>"],
save = saveSpell,
parse = parseSpell,
},
Expand Down Expand Up @@ -828,7 +828,7 @@ Parrot:RegisterSecondaryTriggerCondition {
name = L["Spell"],
desc = L["Buff name or spell id"],
type = 'string',
usage = "<Buff name or spell id>",
usage = L["<Buff name or spell id>"],
save = saveSpell,
parse = parseSpell,
},
Expand Down Expand Up @@ -879,7 +879,7 @@ Parrot:RegisterSecondaryTriggerCondition {
name = L["Spell"],
desc = L["Buff name or spell id"],
type = 'string',
usage = "<Buff name or spell id>",
usage = L["<Buff name or spell id>"],
save = saveSpell,
parse = parseSpell,
},
Expand Down Expand Up @@ -934,7 +934,7 @@ Parrot:RegisterSecondaryTriggerCondition {
name = L["Spell"],
desc = L["Buff name or spell id"],
type = 'string',
usage = "<Buff name or spell id>",
usage = L["<Buff name or spell id>"],
save = saveSpell,
parse = parseSpell,
},
Expand Down Expand Up @@ -985,7 +985,7 @@ Parrot:RegisterSecondaryTriggerCondition {
name = L["Spell"],
desc = L["Buff name or spell id"],
type = 'string',
usage = "<Buff name or spell id>",
usage = L["<Buff name or spell id>"],
save = saveSpell,
parse = parseSpell,
},
Expand Down
2 changes: 1 addition & 1 deletion Data/CombatEvents.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _, ns = ...
local Parrot = ns.addon
local mod = Parrot:NewModule("CombatEventsData")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_CombatEvents_Data")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local newList = Parrot.newList

Expand Down
2 changes: 1 addition & 1 deletion Data/CombatStatus.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local _, ns = ...
local Parrot = ns.addon
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_CombatStatus")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

Parrot:RegisterCombatEvent{
category = "Notification",
Expand Down
2 changes: 1 addition & 1 deletion Data/Cooldowns.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _, ns = ...
local Parrot = ns.addon
local module = Parrot:NewModule("Cooldowns", "AceEvent-3.0", "AceTimer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_Cooldowns")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local newList, del = Parrot.newList, Parrot.del

Expand Down
2 changes: 1 addition & 1 deletion Data/Loot.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local _, ns = ...
local Parrot = ns.addon
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_Loot")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local newDict = Parrot.newDict
local Deformat = Parrot.Deformat
Expand Down
2 changes: 1 addition & 1 deletion Data/PointGains.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _, ns = ...
local Parrot = ns.addon
local module = Parrot:NewModule("PointGains")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_PointGains")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local newDict, newList = Parrot.newDict, Parrot.newList
local Deformat = Parrot.Deformat
Expand Down
2 changes: 1 addition & 1 deletion Data/TriggerConditions.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _, ns = ...
local Parrot = ns.addon
local module = Parrot:NewModule("TriggerConditionsData", "AceEvent-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_TriggerConditions_Data")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")

local newList = Parrot.newList

Expand Down
127 changes: 70 additions & 57 deletions Locales/Babelfish.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,90 @@
--[[
Prefix to all files if this script is run from a subdir, for example
]]
local filePrefix = "../"
local file_prefix = "../"

local allfiles = {
Parrot = { "Code/Parrot.lua", },
Parrot_CombatEvents = { "Code/CombatEvents.lua", },
Parrot_Display = { "Code/Display.lua", },
Parrot_ScrollAreas = { "Code/ScrollAreas.lua", },
Parrot_Suppressions = { "Code/Suppressions.lua", },
Parrot_Triggers = { "Code/Triggers.lua", },
Parrot_AnimationStyles = { "Data/AnimationStyles.lua", },
Parrot_Auras = { "Data/Auras.lua", },
Parrot_CombatEvents_Data = { "Data/CombatEvents.lua", },
Parrot_CombatStatus = { "Data/CombatStatus.lua", },
Parrot_Cooldowns = { "Data/Cooldowns.lua", },
Parrot_Loot = { "Data/Loot.lua", },
Parrot_PointGains = { "Data/PointGains.lua", },
Parrot_TriggerConditions_Data = { "Data/TriggerConditions.lua", },
local all_files = {
"Code/Parrot.lua",
"Code/CombatEvents.lua",
"Code/Display.lua",
"Code/ScrollAreas.lua",
"Code/Suppressions.lua",
"Code/Triggers.lua",
"Data/AnimationStyles.lua",
"Data/Auras.lua",
"Data/CombatEvents.lua",
"Data/CombatStatus.lua",
"Data/Cooldowns.lua",
"Data/Loot.lua",
"Data/PointGains.lua",
"Data/TriggerConditions.lua",
}

local ordered = { -- order in the locale files
"Parrot",
"Parrot_CombatEvents",
"Parrot_Display",
"Parrot_ScrollAreas",
"Parrot_Suppressions",
"Parrot_Triggers",
"Parrot_AnimationStyles",
"Parrot_Auras",
"Parrot_CombatEvents_Data",
"Parrot_CombatStatus",
"Parrot_Cooldowns",
"Parrot_Loot",
"Parrot_PointGains",
"Parrot_TriggerConditions_Data",
local locale_files = {
"deDE", "esES", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW",
}

local function parseFile(filename)
local strings = {}
local file = assert(io.open(string.format("%s%s", filePrefix or "", filename), "r"), "Could not open " .. filename)
local text = file:read("*all")
file:close()
-- extract data
local strings = {}
print("Parsing files")
for _, file in next, all_files do
local fh = assert(io.open(string.format("%s%s", file_prefix or "", file), "r"), "Could not open " .. file)
local text = fh:read("*all")
fh:close()

local count = 0
for match in string.gmatch(text, "L%[\"(.-)\"%]") do
strings[match] = true
count = count + 1
end
return strings
print(" (" .. count .. ")\t" .. file)
end

print("\nGenerating locales")

local locale = io.open("Strings-enUS.lua", "w")
locale:write('local debug = nil\n--@debug@\ndebug = true\n--@end-debug@')
-- dump the english locale
local sorted = {}
for key in next, strings do
table.insert(sorted, key)
end
table.sort(sorted)

-- extract data from specified lua files
for _, namespace in ipairs(ordered) do
print(namespace)
for _, file in ipairs(allfiles[namespace]) do
local strings = parseFile(file)
local locale = assert(io.open("enUS.lua", "wb"), "Could not open enUS.lua")
locale:write('local debug = true\r\n--@debug@\r\ndebug = nil\r\n--@end-debug@')
locale:write('\r\n\r\nlocal L = LibStub("AceLocale-3.0"):NewLocale("Parrot", "enUS", true, debug)\r\n\r\n')

local sorted = {}
for k in next, strings do
table.insert(sorted, k)
end
table.sort(sorted)
for _, v in ipairs(sorted) do
locale:write(string.format('L["%s"] = true\r\n', v))
end
locale:close()
print(" (" .. #sorted .. ")\tenUS")

locale:write(string.format('\n\nlocal L = LibStub("AceLocale-3.0"):NewLocale("%s", "enUS", true, debug)\n', namespace))
for _, v in ipairs(sorted) do
locale:write(string.format('L["%s"] = true\n', v))
end
-- dump the rest
local L
local m = { NewLocale = function() L = {} return L end }
_G.LibStub = setmetatable({}, { __call = function() return m end })

for _, file in next, locale_files do
dofile(string.format("%sLocales/%s.lua", file_prefix or "", file))

print(" (" .. #sorted .. ") " .. file)
local locale = assert(io.open(string.format("%sLocales/%s.lua", file_prefix or "", file), "wb"), "Could not open " .. file)
locale:write('local L = LibStub("AceLocale-3.0"):NewLocale("Parrot", "' .. file .. '")')
if file == "esES" then
locale:write(' or LibStub("AceLocale-3.0"):NewLocale("Parrot", "esMX")')
end
end
locale:write('\r\nif not L then return end\r\n\r\n')

locale:close()
local count = 0
for index, key in ipairs(sorted) do
local value = L[key]
if value then
value = value:gsub("\n", "\\n"):gsub("\"", "\\\"")
locale:write(string.format('L["%s"] = "%s"\r\n', key, value))
count = count + 1
else
locale:write(string.format('-- L["%s"] = "%s"\r\n', key, key))
end
end
locale:close()

print(" (" .. count .. ")\t" .. file)
end
Loading

0 comments on commit dc247c5

Please sign in to comment.