-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8087329
commit 467ffe0
Showing
13 changed files
with
332 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
arb-dir: lib/l10n | ||
template-arb-file: app_en.arb | ||
output-localization-file: app_localizations.dart |
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,86 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:humhub/util/extensions.dart'; | ||
import 'package:humhub/util/override_locale.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
|
||
class LocaleSwitch extends StatefulWidget { | ||
final double width; | ||
static Key userProfileLocaleDropdown = const Key('user_profile_locale_dropdown'); | ||
const LocaleSwitch({ | ||
Key? key, | ||
this.showTitle = false, | ||
this.forceLight = false, | ||
this.width = 100, | ||
}) : super(key: key); | ||
|
||
final bool showTitle; | ||
final bool forceLight; | ||
|
||
@override | ||
State<LocaleSwitch> createState() => _LocaleSwitchState(); | ||
} | ||
|
||
class _LocaleSwitchState extends State<LocaleSwitch> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
width: widget.width, | ||
child: DropdownButtonFormField<int>( | ||
style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).primaryColor), | ||
key: LocaleSwitch.userProfileLocaleDropdown, | ||
selectedItemBuilder: (_) { | ||
return _items | ||
.map( | ||
(e) => Text( | ||
e.toUpperCase(), | ||
), | ||
) | ||
.toList(); | ||
}, | ||
dropdownColor: widget.forceLight ? Colors.white : Theme.of(context).colorScheme.background, | ||
decoration: widget.showTitle | ||
? InputDecoration( | ||
labelText: AppLocalizations.of(context)!.cancel, | ||
enabledBorder: InputBorder.none, | ||
fillColor: Colors.black, | ||
) | ||
: InputDecoration.collapsed( | ||
hintText: AppLocalizations.of(context)!.cancel, | ||
).copyWith( | ||
enabledBorder: InputBorder.none, | ||
focusedBorder: InputBorder.none, | ||
), | ||
isExpanded: true, | ||
value: _value(context), | ||
icon: Icon(Icons.arrow_drop_down, color: Theme.of(context).primaryColor), | ||
items: _items | ||
.mapIndexed( | ||
(text, index) => DropdownMenuItem( | ||
value: index, | ||
child: Text( | ||
text.toUpperCase(), | ||
), | ||
), | ||
) | ||
.toList(), | ||
onChanged: (index) { | ||
if (index == null) return; | ||
Locale? locale = AppLocalizations.supportedLocales.elementAt(index); | ||
OverrideLocale.of(context).changeLocale(locale); | ||
}, | ||
), | ||
); | ||
} | ||
|
||
Iterable<String> get _items => [ | ||
...AppLocalizations.supportedLocales.map((l) => l.languageCode), | ||
]; | ||
|
||
int _value(BuildContext context) { | ||
String localDef = Localizations.localeOf(context).toString(); | ||
final index = AppLocalizations.supportedLocales.indexWhere( | ||
(locale) => localDef == locale.languageCode, | ||
); | ||
return index; | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"cancel" : "Abbrechen", | ||
"help_title" : "Was ist HumHub?", | ||
"help_first_par" : "HumHub ist eine Open-Source-Software, die von Organisationen, Vereinen und Unternehmen hauptsächlich als soziales Netzwerk, Intranet oder Kommunikationsplattform genutzt wird." | ||
} |
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,5 @@ | ||
{ | ||
"cancel" : "Cancel", | ||
"help_title" : "What is HumHub?", | ||
"help_first_par" : "HumHub is an Open Source software used by organizations, associations and companies mainly as social network, intranet or communication platform." | ||
} |
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,5 @@ | ||
{ | ||
"cancel" : "Cancelar", | ||
"help_title" : "¿Qué es HumHub?", | ||
"help_first_par" : "HumHub es un software de código abierto utilizado principalmente por organizaciones, asociaciones y empresas como red social, intranet o plataforma de comunicación." | ||
} |
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
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
Oops, something went wrong.