Browse Source

Sprint 2 // User Story

Mas files del user story
carlos.perez25 3 years ago
parent
commit
9dcd427097
3 changed files with 72 additions and 0 deletions
  1. 15
    0
      Carlos/en.json
  2. 15
    0
      Carlos/es.json
  3. 42
    0
      Carlos/language_constants.dart

+ 15
- 0
Carlos/en.json View File

@@ -0,0 +1,15 @@
1
+{
2
+  "home_page": "Home Page",
3
+  "personal_information": "Personal Information",
4
+  "name": "Name",
5
+  "name_hint": "Enter your name",
6
+  "email": "Email",
7
+  "email_hint": "Enter your email",
8
+  "date_of_birth": "Date of Birth",
9
+  "required_field": "Required Field",
10
+  "submit_info": "Submit Info",
11
+  "about_us": "About Us",
12
+  "settings": "Settings",
13
+  "change_language": "Change Language",
14
+  "about": "This user story translate for our FastMed app in CCOM4030."
15
+}

+ 15
- 0
Carlos/es.json View File

@@ -0,0 +1,15 @@
1
+{
2
+  "home_page": "Pagina Inicio",
3
+  "personal_information": "Informacion Personal",
4
+  "name": "Nombre",
5
+  "name_hint": "Entra tu nombre",
6
+  "email": "Correo electronico",
7
+  "email_hint": "Entra tu correo electronico",
8
+  "date_of_birth": "Fecha de nacimiento",
9
+  "required_field": "Campo requerido",
10
+  "submit_info": "Somete informacion",
11
+  "about_us": "Acerca de nosotros",
12
+  "settings": "Configuracion",
13
+  "change_language": "Cambia el lenguaje",
14
+  "about": "Este user story traduce para nuestro FastMed app en CCOM4030."
15
+}

+ 42
- 0
Carlos/language_constants.dart View File

@@ -0,0 +1,42 @@
1
+import 'package:flutter/material.dart';
2
+import 'package:userstory2translate/localization/localization.dart';
3
+import 'package:shared_preferences/shared_preferences.dart';
4
+
5
+const String LAGUAGE_CODE = 'languageCode';
6
+
7
+//languages code
8
+const String ENGLISH = 'en';
9
+const String FARSI = 'fa';
10
+const String SPANISH = 'es';
11
+const String HINDI = 'hi';
12
+
13
+Future<Locale> setLocale(String languageCode) async {
14
+  SharedPreferences _prefs = await SharedPreferences.getInstance();
15
+  await _prefs.setString(LAGUAGE_CODE, languageCode);
16
+  return _locale(languageCode);
17
+}
18
+
19
+Future<Locale> getLocale() async {
20
+  SharedPreferences _prefs = await SharedPreferences.getInstance();
21
+  String languageCode = _prefs.getString(LAGUAGE_CODE) ?? "en";
22
+  return _locale(languageCode);
23
+}
24
+
25
+Locale _locale(String languageCode) {
26
+  switch (languageCode) {
27
+    case ENGLISH:
28
+      return Locale(ENGLISH, 'US');
29
+    case FARSI:
30
+      return Locale(FARSI, "IR");
31
+    case SPANISH:
32
+      return Locale(SPANISH, "SP");
33
+    case HINDI:
34
+      return Locale(HINDI, "IN");
35
+    default:
36
+      return Locale(ENGLISH, 'US');
37
+  }
38
+}
39
+
40
+String getTranslated(BuildContext context, String key) {
41
+  return DemoLocalization.of(context).translate(key);
42
+}