-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from iseeyoucopy/main
New feature alert with gps coordinates
- Loading branch information
Showing
10 changed files
with
189 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,40 @@ | ||
Locales = {} | ||
|
||
function _(str, ...) -- Translate string | ||
|
||
if Locales[Config.defaultlang] ~= nil then | ||
local translationCache = {} -- Cache for translations | ||
|
||
if Locales[Config.defaultlang][str] ~= nil then | ||
return string.format(Locales[Config.defaultlang][str], ...) | ||
else | ||
return 'Translation [' .. Config.defaultlang .. '][' .. str .. '] does not exist' | ||
end | ||
function _(str, ...) -- Translate string | ||
-- Check cache first | ||
if translationCache[str] then | ||
return string.format(translationCache[str], ...) | ||
end | ||
|
||
else | ||
return 'Locale [' .. Config.defaultlang .. '] does not exist' | ||
end | ||
local lang = Config.defaultlang | ||
local defaultLang = "en_lang" -- Set your fallback language here (e.g., 'en') | ||
|
||
if Locales[lang] ~= nil then | ||
if Locales[lang][str] ~= nil then | ||
translationCache[str] = Locales[lang][str] -- Cache the translation for faster future access | ||
if ... then | ||
return string.format(Locales[lang][str], ...) | ||
else | ||
return Locales[lang][str] | ||
end | ||
elseif Locales[defaultLang] ~= nil and Locales[defaultLang][str] ~= nil then | ||
if ... then | ||
return string.format(Locales[defaultLang][str], ...) | ||
else | ||
return Locales[defaultLang][str] | ||
end | ||
else | ||
return 'Translation [' .. lang .. '][' .. str .. '] and fallback [' .. defaultLang .. '] do not exist' | ||
end | ||
else | ||
return 'Locale [' .. lang .. '] does not exist' | ||
end | ||
end | ||
|
||
function _U(str, ...) -- Translate string first char uppercase | ||
return tostring(_(str, ...):gsub("^%l", string.upper)) | ||
end | ||
-- Use cached translation if available | ||
local translation = _(str, ...) | ||
return translation:sub(1, 1):upper() .. translation:sub(2) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<0.5.0> | ||
<1.0.0> | ||
See GitHub for details! |