Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate locale file from csv file #18

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
*.log
*.pyc
*.swp
*.g.dart
.DS_Store
.atom/
.buildlog/
18 changes: 9 additions & 9 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:easy_localization_loader/easy_localization_loader.dart';
import 'package:example/utils/multi-languages/locale_keys_from_csv.dart';
import 'package:flutter/material.dart';

import 'lang_view.dart';
import 'utils/multi-languages/locale_keys.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();

runApp(EasyLocalization(
supportedLocales: LocaleKeys.supportedLocales,
supportedLocales: LocaleKeysFromCsv.supportedLocales,
path: 'resources/langs/langs.csv',
// fallbackLocale: Locale('en', 'US'),
// startLocale: Locale('de', 'DE'),
@@ -76,7 +76,7 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(LocaleKeys.title).tr(),
title: const Text(LocaleKeysFromCsv.title).tr(),
//Text(AppLocalizations.of(context).tr('title')),
actions: <Widget>[
ElevatedButton(
@@ -107,14 +107,14 @@ class _MyHomePageState extends State<MyHomePage> {
flex: 1,
),
Text(
"LocaleKeys.gender",
"LocaleKeysFromCsvFromCsvs.gender",
style: TextStyle(
color: Colors.grey.shade600,
fontSize: 19,
fontWeight: FontWeight.bold),
).tr(args: ['aissat'], gender: _gender ? 'female' : 'male'),
Text(
LocaleKeys.title.tr(),
LocaleKeysFromCsv.title.tr(),
style: TextStyle(
color: Colors.grey.shade600,
fontSize: 15,
@@ -131,15 +131,15 @@ class _MyHomePageState extends State<MyHomePage> {
const Spacer(
flex: 1,
),
const Text(LocaleKeys.msg).tr(args: ['aissat', 'Flutter']),
const Text(LocaleKeys.msgNamed)
const Text(LocaleKeysFromCsv.msg).tr(args: ['aissat', 'Flutter']),
const Text(LocaleKeysFromCsv.msgNamed)
.tr(namedArgs: {'lang': 'Dart'}, args: ['Easy localization']),
const Text(""),
ElevatedButton(
onPressed: () {
context.setLocale(const Locale('vi'));
context.setLocale(const Locale('vi', 'VN'));
},
child: const Text(LocaleKeys.clickMe).tr(),
child: const Text(LocaleKeysFromCsv.clickMe).tr(),
),
const SizedBox(
height: 15,
1 change: 0 additions & 1 deletion example/lib/utils/multi-languages/locale_keys.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dart:ui';
import 'package:sheet_loader_localization/sheet_loader_localization.dart';
part "locale_keys.g.dart";

53 changes: 0 additions & 53 deletions example/lib/utils/multi-languages/locale_keys.g.dart

This file was deleted.

8 changes: 8 additions & 0 deletions example/lib/utils/multi-languages/locale_keys_from_csv.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:sheet_loader_localization/sheet_loader_localization.dart';

import 'dart:ui' show Locale;

part 'locale_keys_from_csv.g.dart';

@LocalCsvLocalization(path: 'resources/langs/', sourceFile: 'langs.csv')
class _LocaleKeysFromCsv {}
Loading