Multiple changes around Zictionary (mostly for Vietnamese) (#1069)
* Multiple changes - Edit Vietnamese Zictionary - Add STRING.viRemoveDiacritics() - Edit the search behavior with string written in Vietnamese without diacritics * Small changes * Update lang_vi.lua * Small change
This commit is contained in:
committed by
GitHub
parent
43215dfc4b
commit
42942d1ac4
@@ -18,6 +18,7 @@ local lastSelected -- Last selected item
|
||||
|
||||
local currentFontSize=25 -- Current font size, default: 25
|
||||
local needLowerUTF8
|
||||
local isLangVi -- There are special handlings that only for Vietnamese --SweetSea--
|
||||
|
||||
local typeColor={
|
||||
help=COLOR.Y,
|
||||
@@ -45,8 +46,10 @@ local function _scanDict(D)
|
||||
local O=D[i]
|
||||
O.title,O.title_Org=_filter(O[1])
|
||||
O.titleLowered=needLowerUTF8 and STRING.lowerUTF8(O.title) or O.title:lower()
|
||||
O.titleNoDiaratics=isLangVi and STRING.viRemoveDiacritics(O.titleLowered)
|
||||
O.keywords=O[2]
|
||||
O.keywordsLowered=needLowerUTF8 and STRING.lowerUTF8(O.keywords) or O.keywords:lower()
|
||||
O.keywordsNoDiaratics=isLangVi and STRING.viRemoveDiacritics(O.keywordsLowered)
|
||||
O.type=O[3]
|
||||
O.content,O.content_Org=_filter(O[4])
|
||||
O.url=O[5]
|
||||
@@ -92,7 +95,7 @@ local function _search()
|
||||
_clearResult()
|
||||
input=needLowerUTF8 and STRING.lowerUTF8(input) or input:lower()
|
||||
for i=1,#dict do
|
||||
pos=find(dict[i].titleLowered,input,nil,true) or find(STRING.lowerUTF8(dict[i].keywordsLowered),input,nil,true)
|
||||
pos=find(dict[i].titleLowered,input,nil,true) or find(dict[i].keywordsLowered,input,nil,true) or isLangVi and (find(dict[i].titleNoDiaratics,input,nil,true) or find(dict[i].keywordsNoDiaratics,input,nil,true))
|
||||
if pos==1 and not first then
|
||||
ins(result,1,dict[i])
|
||||
first=true
|
||||
@@ -145,6 +148,7 @@ function scene.enter()
|
||||
'en'
|
||||
)
|
||||
needLowerUTF8=SETTING.locale:find'vi'
|
||||
isLangVi=SETTING.locale:find'vi' -- DO NOT CHANGE THIS! --SweetSea--
|
||||
|
||||
dict=require(localeFile)
|
||||
_scanDict(dict)
|
||||
@@ -228,13 +232,13 @@ function scene.keyDown(key)
|
||||
-- MES.new("error","Hotload failed! May need restarting!\n\n"..table.concat(_r,"\n"))
|
||||
-- else
|
||||
-- local lastLscrollPos=listBox.scrollPos
|
||||
-- local lastTscrollPos=textBox.scrollPos
|
||||
-- local lastTscrollPos=contentBox.scrollPos
|
||||
-- listBox:setList(_getList())
|
||||
-- if #inputBox:getText()>0 then _search() end
|
||||
-- listBox.selected=lastSelected<#dict and lastSelected or #dict -- In case the last item is removed!
|
||||
-- listBox.scrollPos=lastLscrollPos
|
||||
-- _updateInfoBox()
|
||||
-- textBox.scrollPos=lastTscrollPos
|
||||
-- _updateContentBox()
|
||||
-- contentBox.scrollPos=lastTscrollPos
|
||||
-- SFX.play('pc')
|
||||
-- end
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user