Skip to content

Commit a23ef4c

Browse files
author
Tensor-Programming
authored
added localization
1 parent f309890 commit a23ef4c

15 files changed

+355
-19
lines changed

lib/const.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
const API_KEY = '[API KEY HERE]';
1+
const API_KEY = '78b288f2b2d9382cb2cc9436e08cd916';

lib/l10n/intl_en.arb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"title": "Weather Application",
3+
"@title": {
4+
"description": "Title for the Weather application",
5+
"type": "text"
6+
},
7+
8+
"button": "Get the Weather",
9+
"@button": {
10+
"description": "get weather button",
11+
"type": "text",
12+
"placeholders": {}
13+
}
14+
}

lib/l10n/intl_es.arb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"title": "Aplicación Meteorológica",
3+
"@title": {
4+
"description": "Title for the Weather application",
5+
"type": "text"
6+
},
7+
8+
"button": "obtener el clima",
9+
"@button": {
10+
"description": "get weather button",
11+
"type": "text",
12+
"placeholders": {}
13+
}
14+
}

lib/l10n/intl_ja.arb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"title": "天気アプリケーション",
3+
"@title": {
4+
"description": "Title for the Weather application",
5+
"type": "text"
6+
},
7+
"button": "天気を取る",
8+
"@button": {
9+
"description": "get weather button",
10+
"type": "text",
11+
"placeholders": {}
12+
}
13+
14+
}

lib/l10n/intl_messages.arb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"@@last_modified": "2018-04-27T17:16:00.180810",
3+
"title": "Weather Application",
4+
"@title": {
5+
"description": "Title for the Weather Application",
6+
"type": "text",
7+
"placeholders": {}
8+
},
9+
"button": "Get the Weather",
10+
"@button": {
11+
"description": "get weather button",
12+
"type": "text",
13+
"placeholders": {}
14+
}
15+
}

lib/l10n/messages_all.dart

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2+
// This is a library that looks up messages for specific locales by
3+
// delegating to the appropriate library.
4+
5+
import 'dart:async';
6+
7+
import 'package:intl/intl.dart';
8+
import 'package:intl/message_lookup_by_library.dart';
9+
// ignore: implementation_imports
10+
import 'package:intl/src/intl_helpers.dart';
11+
12+
import 'messages_es.dart' as messages_es;
13+
import 'messages_en.dart' as messages_en;
14+
import 'messages_messages.dart' as messages_messages;
15+
import 'messages_ja.dart' as messages_ja;
16+
17+
typedef Future<dynamic> LibraryLoader();
18+
Map<String, LibraryLoader> _deferredLibraries = {
19+
'es': () => new Future.value(null),
20+
'en': () => new Future.value(null),
21+
'messages': () => new Future.value(null),
22+
'ja': () => new Future.value(null),
23+
};
24+
25+
MessageLookupByLibrary _findExact(localeName) {
26+
switch (localeName) {
27+
case 'es':
28+
return messages_es.messages;
29+
case 'en':
30+
return messages_en.messages;
31+
case 'messages':
32+
return messages_messages.messages;
33+
case 'ja':
34+
return messages_ja.messages;
35+
default:
36+
return null;
37+
}
38+
}
39+
40+
/// User programs should call this before using [localeName] for messages.
41+
Future<bool> initializeMessages(String localeName) async {
42+
var availableLocale = Intl.verifiedLocale(
43+
localeName,
44+
(locale) => _deferredLibraries[locale] != null,
45+
onFailure: (_) => null);
46+
if (availableLocale == null) {
47+
return new Future.value(false);
48+
}
49+
var lib = _deferredLibraries[availableLocale];
50+
await (lib == null ? new Future.value(false) : lib());
51+
initializeInternalMessageLookup(() => new CompositeMessageLookup());
52+
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
53+
return new Future.value(true);
54+
}
55+
56+
bool _messagesExistFor(String locale) {
57+
try {
58+
return _findExact(locale) != null;
59+
} catch (e) {
60+
return false;
61+
}
62+
}
63+
64+
MessageLookupByLibrary _findGeneratedMessagesFor(locale) {
65+
var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor,
66+
onFailure: (_) => null);
67+
if (actualLocale == null) return null;
68+
return _findExact(actualLocale);
69+
}

lib/l10n/messages_en.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2+
// This is a library that provides messages for a en locale. All the
3+
// messages from the main program should be duplicated here with the same
4+
// function name.
5+
6+
import 'package:intl/intl.dart';
7+
import 'package:intl/message_lookup_by_library.dart';
8+
9+
final messages = new MessageLookup();
10+
11+
// ignore: unused_element
12+
final _keepAnalysisHappy = Intl.defaultLocale;
13+
14+
// ignore: non_constant_identifier_names
15+
typedef MessageIfAbsent(String message_str, List args);
16+
17+
class MessageLookup extends MessageLookupByLibrary {
18+
get localeName => 'en';
19+
20+
final messages = _notInlinedMessages(_notInlinedMessages);
21+
static _notInlinedMessages(_) => <String, Function>{
22+
"title": MessageLookupByLibrary.simpleMessage("Weather Application"),
23+
"button": MessageLookupByLibrary.simpleMessage("Get the Weather")
24+
};
25+
}

lib/l10n/messages_es.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2+
// This is a library that provides messages for a es locale. All the
3+
// messages from the main program should be duplicated here with the same
4+
// function name.
5+
6+
import 'package:intl/intl.dart';
7+
import 'package:intl/message_lookup_by_library.dart';
8+
9+
final messages = new MessageLookup();
10+
11+
// ignore: unused_element
12+
final _keepAnalysisHappy = Intl.defaultLocale;
13+
14+
// ignore: non_constant_identifier_names
15+
typedef MessageIfAbsent(String message_str, List args);
16+
17+
class MessageLookup extends MessageLookupByLibrary {
18+
get localeName => 'es';
19+
20+
final messages = _notInlinedMessages(_notInlinedMessages);
21+
static _notInlinedMessages(_) => <String, Function>{
22+
"title":
23+
MessageLookupByLibrary.simpleMessage("Aplicación Meteorológica"),
24+
"button": MessageLookupByLibrary.simpleMessage("Obtener el Clima")
25+
};
26+
}

lib/l10n/messages_ja.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2+
// This is a library that provides messages for a ja locale. All the
3+
// messages from the main program should be duplicated here with the same
4+
// function name.
5+
6+
import 'package:intl/intl.dart';
7+
import 'package:intl/message_lookup_by_library.dart';
8+
9+
final messages = new MessageLookup();
10+
11+
// ignore: unused_element
12+
final _keepAnalysisHappy = Intl.defaultLocale;
13+
14+
// ignore: non_constant_identifier_names
15+
typedef MessageIfAbsent(String message_str, List args);
16+
17+
class MessageLookup extends MessageLookupByLibrary {
18+
get localeName => 'ja';
19+
20+
final messages = _notInlinedMessages(_notInlinedMessages);
21+
static _notInlinedMessages(_) => <String, Function>{
22+
"title": MessageLookupByLibrary.simpleMessage("天気アプリケーション"),
23+
"button": MessageLookupByLibrary.simpleMessage("天気を取る")
24+
};
25+
}

lib/l10n/messages_messages.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2+
// This is a library that provides messages for a messages locale. All the
3+
// messages from the main program should be duplicated here with the same
4+
// function name.
5+
6+
import 'package:intl/intl.dart';
7+
import 'package:intl/message_lookup_by_library.dart';
8+
9+
final messages = new MessageLookup();
10+
11+
// ignore: unused_element
12+
final _keepAnalysisHappy = Intl.defaultLocale;
13+
14+
// ignore: non_constant_identifier_names
15+
typedef MessageIfAbsent(String message_str, List args);
16+
17+
class MessageLookup extends MessageLookupByLibrary {
18+
get localeName => 'messages';
19+
20+
final messages = _notInlinedMessages(_notInlinedMessages);
21+
static _notInlinedMessages(_) => <String, Function>{
22+
"title": MessageLookupByLibrary.simpleMessage("Weather Application"),
23+
"button": MessageLookupByLibrary.simpleMessage("Get the Weather")
24+
};
25+
}

0 commit comments

Comments
 (0)