-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes in the way the translation files are generated
To generate a better experience and avoid mismatches between the state of the different languages I generated a script that compares the files. When run 'npm run translations' the file './i18n/generic.json' is self-generated with all strings extracted from the application. After that the own script (i18n-diff.js) is executed, which returns the missing or oversubscribed translations in each language located in the i18n/translations folder. Throughout the previous commits I was removing and correcting mistakes of typing and lost translations according to what different people were reporting.
- Loading branch information
Showing
7 changed files
with
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
"plugins": [ | ||
"preact-i18nline" | ||
], | ||
"outputFile": "i18n/translations/en.json" | ||
"outputFile": "i18n/generic.json" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
const genericFile = require('./i18n/generic.json').en; | ||
const translations = require('./i18n'); | ||
const colors = require('colors'); | ||
|
||
const missing = (master, slave) => { | ||
const slaveKeys = Object.keys(slave); | ||
return Object.keys(master).filter(key => slaveKeys.indexOf(key)=== -1); | ||
}; | ||
|
||
const surplus = (master, slave) => { | ||
const masterKeys = Object.keys(master); | ||
return Object.keys(slave).filter(key => masterKeys.indexOf(key) === -1); | ||
}; | ||
|
||
const init = () => { | ||
console.log(colors.bold.underline('Translations differences')); | ||
|
||
const translationsKeys = Object.keys(translations); | ||
|
||
translationsKeys.forEach((lang) => { | ||
const translationsMissing = missing(genericFile,translations[lang]); | ||
const translationsSurplus = surplus(genericFile,translations[lang]); | ||
|
||
console.log(colors.bold(' ./i18n/translations/' + lang + '.json')) | ||
translationsMissing.map(x => console.log(colors.green(' +++ '+ x))) | ||
translationsSurplus.map(x => console.log(colors.red(' --- '+ x))) | ||
}); | ||
}; | ||
|
||
init(); |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"en": { | ||
"align_11050992": "Align", | ||
"interfaces_44f8a99c": "Interfaces", | ||
"stations_18122820": "Stations", | ||
"config_4877f466": "Config", | ||
"current_status_830c5a75": "Current status", | ||
"connected_host_91e11459": "Connected Host", | ||
"base_host_a17d45a4": "Base Host", | ||
"select_new_base_station_3652ae73": "Select new base station", | ||
"change_dcaa253a": "Change", | ||
"locate_5f6685db": "Locate", | ||
"station_75bce853": "Station", | ||
"move_to_new_position_eb97c4c3": "MOVE TO NEW POSITION", | ||
"packet_loss_1afe48a8": "Packet loss", | ||
"metrics_c80fba05": "Metrics", | ||
"metrics_status_gateway_2a77a113": "metrics_status_gateway", | ||
"metrics_status_path_905a8d22": "metrics_status_path", | ||
"metrics_status_stations_464641e8": "metrics_status_stations", | ||
"load_last_known_internet_path_677f6229": "load_last_known_internet_path", | ||
"only_gateway_727b1656": "Only gateway", | ||
"full_path_metrics_2859608f": "Full path metrics", | ||
"internet_connection_fda60ffa": "Internet connection", | ||
"from_fdd4956d": "From", | ||
"to_internet_494eb85c": "To Internet", | ||
"notes_c42e0fd5": "Notes", | ||
"notes_of_a44a4158": "Notes of", | ||
"save_notes_616850ea": "Save notes", | ||
"status_e7fdbe06": "Status", | ||
"system_55b0ca91": "System", | ||
"uptime_c1d2415d": "Uptime", | ||
"most_active_2d5a3cae": "Most Active", | ||
"interface_177dac54": "Interface", | ||
"traffic_bfe536d2": "Traffic", | ||
"loading_node_status_547ed318": "Loading node status...", | ||
"ip_addresses_440ac240": "IP Addresses", | ||
"back_to_base_443797cb": "Back to base", | ||
"trying_to_connect_ff82bf9f": "Trying to connect" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require('fs').readdirSync(__dirname + '/translations/').forEach((file) => { | ||
if (file.match(/\.json$/) !== null) { | ||
let name = file.replace('.json', ''); | ||
exports[name] = require('./translations/' + file); | ||
} | ||
}); |
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