Skip to content

Commit

Permalink
fix: resolve ci errors and wanrings
Browse files Browse the repository at this point in the history
  • Loading branch information
flexiondotorg committed Jan 12, 2025
1 parent 72edcd4 commit d77bd80
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
19 changes: 10 additions & 9 deletions smiti18n/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local unpack = unpack or table.unpack -- lua 5.2 compat
local i18n = {}

local store
Expand Down Expand Up @@ -67,17 +68,17 @@ local function assertFunctionOrNil(functionName, paramName, value)
error(msg:format(functionName, paramName, tostring(value), type(value)))
end

local function defaultPluralizeFunction(locale, count)
if not locale then
locale = i18n.getLocale()
if type(locale) == "table" then
locale = locale[1]
local function defaultPluralizeFunction(loc, count)
if not loc then
loc = i18n.getLocale()
if type(loc) == "table" then
loc = loc[1]
end
end
return plural.get(variants.root(locale), count)
return plural.get(variants.root(loc), count)
end

local function pluralize(t, locale, data)
local function pluralize(t, loc, data)
assertPresentOrPlural('interpolatePluralTable', 't', t)
data = data or {}
local key
Expand All @@ -92,7 +93,7 @@ local function pluralize(t, locale, data)
if customPluralizeFunction then
plural_form = customPluralizeFunction(count)
else
plural_form = defaultPluralizeFunction(locale, count)
plural_form = defaultPluralizeFunction(loc, count)
end
return t[plural_form]
end
Expand All @@ -102,7 +103,7 @@ local function treatNode(node, loc, data)
local iter = {ipairs(node)}
node = {}
for k,v in unpack(iter) do
node[k] = treatNode(v, data)
node[k] = treatNode(v, loc, data)
end
elseif type(node) == 'string' then
return interpolate(node, data)
Expand Down
12 changes: 6 additions & 6 deletions smiti18n/variants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ local function reverse(arr, length)
return result, length
end

local function concat(arr1, len1, arr2, len2)
for i = 1, len2 do
arr1[len1 + i] = arr2[i]
end
return arr1, len1 + len2
end
--local function concat(arr1, len1, arr2, len2)
-- for i = 1, len2 do
-- arr1[len1 + i] = arr2[i]
-- end
-- return arr1, len1 + len2
--end

function variants.ancestry(locale)
local result, length, accum = {},0,nil
Expand Down

0 comments on commit d77bd80

Please # to comment.