forked from iampawan/Flutter-UI-Kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multilingual Support added - Working only for Login otp screen for no…
…w and only supports hindi and english language as of now
- Loading branch information
Showing
8 changed files
with
167 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'dart:async'; | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart' show rootBundle; | ||
|
||
class Translations { | ||
Translations(Locale locale) { | ||
this.locale = locale; | ||
_localizedValues = null; | ||
} | ||
|
||
Locale locale; | ||
static Map<dynamic, dynamic> _localizedValues; | ||
|
||
static Translations of(BuildContext context) { | ||
return Localizations.of<Translations>(context, Translations); | ||
} | ||
|
||
String text(String key) { | ||
return _localizedValues[key] ?? '** $key not found'; | ||
} | ||
|
||
static Future<Translations> load(Locale locale) async { | ||
Translations translations = new Translations(locale); | ||
String jsonContent = | ||
await rootBundle.loadString("locale/i18n_${locale.languageCode}.json"); | ||
_localizedValues = json.decode(jsonContent); | ||
return translations; | ||
} | ||
|
||
get currentLanguage => locale.languageCode; | ||
} | ||
|
||
class TranslationsDelegate extends LocalizationsDelegate<Translations> { | ||
const TranslationsDelegate(); | ||
|
||
@override | ||
bool isSupported(Locale locale) => ['en', 'hi'].contains(locale.languageCode); | ||
|
||
@override | ||
Future<Translations> load(Locale locale) => Translations.load(locale); | ||
|
||
@override | ||
bool shouldReload(TranslationsDelegate old) => false; | ||
} |
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,12 @@ | ||
{ | ||
"app_name":"फ़्लटर यूआई-किट ", | ||
"enter_code_label":"फ़ोन नम्बर", | ||
"enter_code_hint":"10 डिजिट का फ़ोन नम्बर ", | ||
"enter_otp_label":"ओ टी पी", | ||
"enter_otp_hint":"4 डिजिट ओ टी पी", | ||
"get_otp":"ओ टी पी मँगायें ", | ||
"resend_otp":"ओ टी पी दुबारा मँगायें", | ||
"login":"लॉगिन", | ||
"enter_valid_number":"10 डिजिट का ही नम्बर डालें", | ||
"enter_valid_otp":"4 डिजिट का ही ओ टी पी डालें" | ||
} |
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,12 @@ | ||
{ | ||
"app_name":"Flutter UI-Kit ", | ||
"enter_code_label":"Phone Number", | ||
"enter_code_hint":"10 Digit Phone Number", | ||
"enter_otp_label":"OTP", | ||
"enter_otp_hint":"4 Digit OTP", | ||
"get_otp":"Get OTP", | ||
"resend_otp":"Resend OTP", | ||
"login":"Login", | ||
"enter_valid_number":"Enter 10 digit phone number", | ||
"enter_valid_otp":"Enter 4 digit otp" | ||
} |
Oops, something went wrong.