Comments (5)
Hi @bratan I understand your position, but I think that this feature could be useful for apps that need to go in production but not with all translation, for example when there is a deadline but translators did not finish and the company wants to deploy anyway.
In those cases with the current approach we must go manually to set the missing keys to another language, which will then becomes a problem when the translated text must be replaced because there is not a clear way to know if the developers replaced all "fallback" translations into the new localized ones.
With my proposed one in the same situation we could add a "fallback" flag and deploy anyway, and when the translator finished add all keys knowing that if we missed any translation we can use tools like json-diff to find them.
I agree with you that this situation should not happen often (I just set up a CI job to check for missing translations in my project), but It would be useful in some cases
from flutter_translate.
@neokree - Hi, the request is clear but I will not be implementing this behavior since generally there shouldn't be any missing keys.
If you can point out a specific scenario where this behavior would make sense I could reconsider.
from flutter_translate.
Hi @bratan I agree with @neokree. This is also the way native Android apps work. There is a default/fallback language (in our case it's English) for when a key is missing. This has been quite valuable for our app. Most users know English as a second language (if not first) and we support multiple languages. Sometimes, however, we cannot get all translations in time for first release of a feature. And, it is better to show the English translation than to show the name of the key (which is not intended for display).
from flutter_translate.
Agreed with @neokree and @doc-rj.
I created a small script to sync translations when needed (this one sync fr
file with the others but you could change it) :
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
function syncJson(src, target) {
// Ajouter les clés de fr à target
for (let key in src) {
if (typeof src[key] === 'object' && src[key] !== null) {
if (!target.hasOwnProperty(key) || typeof target[key] !== 'object') {
target[key] = {};
}
syncJson(src[key], target[key]);
} else if (!target.hasOwnProperty(key)) {
target[key] = src[key];
}
}
// Supprimer les clés de trad qui n'existent pas dans fr
for (let key in target) {
if (!src.hasOwnProperty(key)) {
delete target[key];
} else if (typeof target[key] === 'object' && target[key] !== null) {
syncJson(src[key], target[key]);
}
}
}
const frPath = path.join(__dirname, '../assets/i18n/fr.json');
let frJson = JSON.parse(fs.readFileSync(frPath, 'utf8'));
fs.writeFileSync(frPath, JSON.stringify(frJson, Object.keys(frJson).sort(), 2), 'utf8');
let langFiles = ['it', 'es', 'ca', 'en']; // ajoutez d'autres langues si nécessaire
for (let langFile of langFiles) {
let targetPath = path.join(__dirname, `../assets/i18n/${langFile}.json`);
let targetJson = fs.existsSync(targetPath) ? JSON.parse(fs.readFileSync(targetPath, 'utf8')) : {};
// synchroniser les fichiers
syncJson(frJson, targetJson);
// écrire le fichier de langue synchronisé
fs.writeFileSync(targetPath, JSON.stringify(targetJson, Object.keys(targetJson).sort(), 2), 'utf8');
}
from flutter_translate.
I can also add that some values, like the languages themselves or the branding, might be untranslatable. So all of these strings can stay in the en.json file (or whatever is the default one) and the library should read them if not found in the other jsons.
from flutter_translate.
Related Issues (20)
- Update packages HOT 4
- Parent Widget not updated HOT 2
- Add information for the deprecated flutter_translate_gen HOT 4
- No MaterialLocalizations found , If change language to Soomaali (so) HOT 2
- reverse back when change language HOT 1
- Language changes, then falls back to default language
- Possible to translate a specific widget? HOT 1
- Simplify configuration & initialization
- Implement a missing key strategy HOT 1
- Implement remote (http) localization loader HOT 1
- universal_io, Question about? HOT 1
- Why flutter_translate_gen has been archived? HOT 1
- Bump version to handle Flutter 3.0
- Load translations from web HOT 2
- Wrap LocalizationProvider for Cubit / BLoC package HOT 1
- Pluralization feature not working for static keys HOT 5
- Localization Issue with OS language changes HOT 1
- Test for web platform is not working HOT 1
- Not fiend flutter_localizations GlobalMaterialLocalizations error HOT 1
- en.json missing from assets HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_translate.