Skip to content

Commit

Permalink
feat: 数字转写 lua 提供「拾万」、「壹拾万」两个选项 close #967
Browse files Browse the repository at this point in the history
  • Loading branch information
mirtlecn committed Jul 27, 2024
1 parent bd5bcce commit 49c1bd7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lua/number_translator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ local function number_translatorFunc(num)
{ number2cnChar(numberPart.int, 0) ..
decimal_func(numberPart.dec, { [1] = "", [2] = "", [3] = "", [4] = "" },
{ [0] = "", "", "", "", "", "", "", "", "", "" }), "〔金额小写〕" })
table.insert(result,
{ number2cnChar(numberPart.int, 1) ..
decimal_func(numberPart.dec, { [1] = "", [2] = "", [3] = "", [4] = "" },
{ [0] = "", "", "", "", "", "", "", "", "", "" }), "〔金额大写〕" })

local number2cnCharInt = number2cnChar(numberPart.int, 1)
local number2cnCharDec = decimal_func(numberPart.dec, { [1] = "", [2] = "", [3] = "", [4] = "" }, { [0] = "", "", "", "", "", "", "", "", "", "" })
table.insert(result, { number2cnCharInt .. number2cnCharDec , "〔金额大写〕"})
if string.len(numberPart.int) > 4 and number2cnCharInt:find('^' .. '拾万') then
number2cnCharInt = number2cnCharInt:gsub('^' .. '拾万', '壹拾万')
table.insert(result, { number2cnCharInt .. number2cnCharDec , "〔金额大写〕"})
end
return result
end

Expand Down

0 comments on commit 49c1bd7

Please sign in to comment.