Skip to content

Commit

Permalink
Optimization by Juju Adams
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarbosa95 committed Apr 11, 2021
1 parent dfe3ab7 commit 915a31f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<h4 align="center">Internationalization of texts simply and quickly, using JSON files</h4>

<p align="center">
<a href="https://github.com/CreativeHandOficial/gm-i18n/releases/tag/v0.0.0">
<img src="https://img.shields.io/badge/release-v0.1.0-%2348af8f" alt="Release v0.1.0">
<a href="https://github.com/CreativeHandOficial/gm-i18n/releases/tag/v0.2.0">
<img src="https://img.shields.io/badge/release-v0.2.0-%2348af8f" alt="Release v0.2.0">
</a>
<a href="https://twitter.com/intent/follow?screen_name=CreativeHandOf">
<img src="https://img.shields.io/twitter/follow/CreativeHandOf.svg?label=Follow%20@CreativeHandOf" alt="Follow @CreativeHandOf" />
Expand Down Expand Up @@ -140,6 +140,28 @@ Returns an array with all the locations configured during setup
getLocales();
```

---
## Contributors


<div align="left">
<table>
<tr align="center">
<td align="center">
<a href="https://github.com/JujuAdams">
<img src="https://avatars.githubusercontent.com/u/3970480?v=4" width="100" />
<br />
<sub>
<b>Juju Adams</b>
</sub>
</a>
<br />
<a href="http://www.jujuadams.com/" title="Juju Adams">🌈</a></td>
</td>
</tr>
</table>
</div>


---
## Author
Expand All @@ -150,10 +172,16 @@ getLocales();
<td>Coded By</td>
</tr>
<tr align="center">
<td>
<td align="center">
<a href="https://github.com/rbarbosa95">
<img src="https://avatars0.githubusercontent.com/u/15218743?s=460&u=d76d008067b2ee2fe2f55db081ea78cdad461e57&v=4" width="100" />
<br />
<sub>
<b>Ramon Barbosa</b>
</sub>
</a>
<br />
<a href="https://creativehand.com.br/" title="Creative Hand">🕹️</a></td>
</td>
</tr>
</table>
Expand Down
6 changes: 3 additions & 3 deletions scripts/gmi18n/gmi18n.gml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function handleFallBackLocaleFile() {

}

//Clear the string cache
// Clear the string cache
ds_map_clear(global.__localizationStringCache);

global.__translatorFallBackLocale = _translator;
Expand Down Expand Up @@ -174,7 +174,7 @@ function handleTranslatorFile() {
throw "Incorrect " + _file + " format";
}

//Clear the string cache
// Clear the string cache
ds_map_clear(global.__localizationStringCache);

global.__translator = _translator;
Expand Down Expand Up @@ -226,7 +226,7 @@ function useTranslation(_param) {
_translatorFallBackLocale = undefined,
_input_param = _param;

//Check the string cache and, if we find a cached result, return it
// Check the string cache and, if we find a cached result, return it
if (ds_map_exists(global.__localizationStringCache, _input_param)) {
return global.__localizationStringCache[? _input_param];
}
Expand Down
14 changes: 3 additions & 11 deletions scripts/utilsGmI18n/utilsGmI18n.gml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/// @function importJson(file_name, func)
/// @param {string} _file_name the file to get the json data from
/// @param {func} _func the function to use on the string
/// @description imports json data form a file. Pass json_decode
/// to return the data as maps and lists. Pass json_parse to
/// return the data as arrays and structs.
/// @author https://github.com/samspadegamedev
function importJson(_file_name, _func) {
if (file_exists(_file_name)) {
var _buffer = buffer_load(_file_name);
Expand All @@ -20,14 +16,10 @@ function importJson(_file_name, _func) {
/// @param {string} _file_name the file to save the json data to
/// @param {struct/array/map} _data the data to save as json data
/// @param {func} _func the function to use on the data
/// @description saves json data to a file. Pass a map and json_encode
/// to return save json data stored as maps and lists. Pass an
/// array or struct and json_parse to save the data stored
/// as arrays and structs.
/// @author https://github.com/samspadegamedev
function exportJson(_file_name, _data, _func) {
var _buffer = buffer_create(string_byte_length(_data)+1, buffer_fixed, 1);
buffer_write(_buffer, buffer_string, script_execute(_func, _data));
var _data_string = script_execute(_func, _data);
var _buffer = buffer_create(string_byte_length(_data_string) + 1, buffer_fixed, 1);
buffer_write(_buffer, buffer_string, _data_string);
buffer_save(_buffer, _file_name);
}

Expand Down

0 comments on commit 915a31f

Please sign in to comment.