File size: 943 Bytes
b6a38d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
local user_location = "AppData/en-us.lua"
local default_location = "CommonAssets/__en-us.lua"
local location = default_location
if FirstLoad then
SpellcheckDict = false
end
function LoadDictionary()
if not Platform.developer then
if not io.exists(user_location) then
AsyncCopyFile(default_location, user_location)
end
location = user_location
end
dofile(location)
end
function WriteToDictionary(dict)
local lines = {}
lines[1] = "SpellcheckDict = {"
for word, _ in sorted_pairs(dict) do
lines[#lines + 1] = "\t[\""..word.."\"] = true,"
end
lines[#lines + 1] = "}"
AsyncStringToFile(location, table.concat(lines, "\n"))
end
function WordInDictionary(word, lowercase_word)
if not SpellcheckDict then
return true
end
if word ~= nil and word ~= "" and not SpellcheckDict[word] and not SpellcheckDict[lowercase_word] and not tonumber(word) and not tonumber(string.sub(word,2)) then
return false
end
return true
end |