Skip to content

Commit

Permalink
Add translations
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Jan 3, 2024
1 parent 4a6497a commit ba00e09
Show file tree
Hide file tree
Showing 11 changed files with 303 additions and 55 deletions.
3 changes: 2 additions & 1 deletion pkgs/sketch_pad/lib/console.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:flutter/material.dart';

import 'l10n/en.flutter.g.dart';
import 'theme.dart';
import 'widgets.dart';

Expand Down Expand Up @@ -77,7 +78,7 @@ class _ConsoleWidgetState extends State<ConsoleWidget> {
builder: (context, value, _) {
return MiniIconButton(
icon: Icons.playlist_remove,
tooltip: 'Clear console',
tooltip: context.messagesLocalizations!.clearConsole,
onPressed: value.text.isEmpty ? null : _clearConsole,
);
},
Expand Down
15 changes: 8 additions & 7 deletions pkgs/sketch_pad/lib/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'l10n/en.g.dart';
import 'theme.dart';

bool get _mac => defaultTargetPlatform == TargetPlatform.macOS;
Expand Down Expand Up @@ -40,13 +41,13 @@ final ShortcutActivator quickFixKeyActivator = SingleActivator(

// map of key activator names

final List<(String, ShortcutActivator)> keyBindings = [
('Code completion', codeCompletionKeyActivator),
('Find', findKeyActivator),
('Find next', findNextKeyActivator),
('Quick fixes', quickFixKeyActivator),
('Reload', reloadKeyActivator),
];
List<(String, ShortcutActivator)> keyBindings(Messages messages) => [
(messages.codeCompletion, codeCompletionKeyActivator),
(messages.find, findKeyActivator),
(messages.findNext, findNextKeyActivator),
(messages.quickFixes, quickFixKeyActivator),
(messages.reload, reloadKeyActivator),
];

extension SingleActivatorExtension on SingleActivator {
// Note that this only works in debug mode.
Expand Down
28 changes: 27 additions & 1 deletion pkgs/sketch_pad/lib/l10n/de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,31 @@
"installSdk": "SDK installieren",
"privacyNotice": "Datenschutzerklärung",
"feedback": "Feedback",
"channelSelection": "{channelName} channel"
"channelSelection": "{channelName} channel",
"toggleBrightness": "Helligkeit umschalten",
"runButton": "Ausführen",
"clearConsole": "Konsole löschen",
"format": "Formatieren",
"noFormattingChanges": "Keine Änderungen beim Formatieren",
"formatSuccesful": "Formatieren erfolgreich",
"errorFormatting": "Fehler beim formatieren",
"compilationFailed": "Kompilierung fehlgeschlagen",
"keyboardShortcuts": "Tastenkombinationen",
"newSnippet": "Neues {type} snippet",
"switchedToDartAndFlutter": "Zu Dart {dartVersion} and Flutter {flutterVersion} gewechselt",
"sharingGuide": "Leitfaden zum Teilen",
"dartpadGithub": "DartPad auf GitHub",
"command": "Befehl",
"keyboardShortcut": "Tastenkombination",
"runtimeVersions": "Runtime-Versionen",
"basedOnDartAndFlutter": "Based on Dart SDK {dartVersion} and Flutter SDK {flutterVersion}",
"experimentsEnabled": "Experiments enabled: {experiments}",
"package": "Paket",
"version": "Version",
"createNewSnippet": "Neues {type} Snippet erstellt",
"codeCompletion": "Code Vervollständigung",
"find": "Finden",
"findNext": "Nächstes finden",
"quickFixes": "Quick-Fixes",
"reload": "Neu laden"
}
2 changes: 1 addition & 1 deletion pkgs/sketch_pad/lib/l10n/de.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[0,"de","8HMbX1u8",0,null,[" channel",[0,0]],"Feedback","SDK installieren","Neu","Datenschutzerklärung","Beispiele"]
[0,"de","fhb5q58f",0,null,["Based on Dart SDK and Flutter SDK ",[18,0],[35,1]],[" channel",[0,0]],"Konsole löschen","Code Vervollständigung","Befehl","Kompilierung fehlgeschlagen",["Neues Snippet erstellt",[6,0]],"DartPad auf GitHub","Fehler beim formatieren",["Experiments enabled: ",[21,0]],"Feedback","Finden","Nächstes finden","Formatieren","Formatieren erfolgreich","SDK installieren","Tastenkombination","Tastenkombinationen","Neu",["Neues snippet",[6,0]],"Keine Änderungen beim Formatieren","Paket","Datenschutzerklärung","Quick-Fixes","Neu laden","Ausführen","Runtime-Versionen","Beispiele","Leitfaden zum Teilen",["Zu Dart and Flutter gewechselt",[8,0],[21,1]],"Helligkeit umschalten","Version"]
135 changes: 135 additions & 0 deletions pkgs/sketch_pad/lib/l10n/en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,140 @@
"example": "Stable"
}
}
},
"toggleBrightness": "Toggle brightness",
"@toggleBrightness": {
"description": "Toggle brightness button tooltip"
},
"runButton": "Run",
"@runButton": {
"description": "Run button"
},
"clearConsole": "Clear console",
"@clearConsole": {
"description": "Clear Console button tooltip"
},
"format": "Format",
"@format": {
"description": "Format tooltip"
},
"noFormattingChanges": "No formatting changes",
"@noFormattingChanges": {
"description": "No formatting changes toast"
},
"formatSuccesful": "Format successful",
"@formatSuccesful": {
"description": "Format succesful toast"
},
"errorFormatting": "Error formatting code",
"@errorFormatting": {
"description": "Error formatting code toast"
},
"compilationFailed": "Compilation failed",
"@compilationFailed": {
"description": "Compilation failed"
},
"keyboardShortcuts": "Keyboard shortcuts",
"@keyboardShortcuts": {
"description": "Keyboard shortcuts tooltip"
},
"newSnippet": "New {type} snippet",
"@newSnippet": {
"description": "New snippet for type",
"placeholders": {
"type": {
"type": "String"
}
}
},
"switchedToDartAndFlutter": "Switched to Dart {dartVersion} and Flutter {flutterVersion}",
"@switchedToDartAndFlutter": {
"description": "switchedToDartAndFlutter",
"placeholders": {
"dartVersion": {
"type": "String"
},
"flutterVersion": {
"type": "String"
}
}
},
"sharingGuide": "Sharing Guide",
"@sharingGuide": {
"description": "Sharing Guide button"
},
"dartpadGithub": "DartPad on GitHub",
"@dartpadGithub": {
"description": "Dartpad on Github button"
},
"command": "Command",
"@command": {
"description": "command table header"
},
"keyboardShortcut": "Keyboard shortcut",
"@keyboardShortcut": {
"description": "Keyboard shortcut table header"
},
"runtimeVersions": "Runtime versions",
"@runtimeVersions": {
"description": "Runtime versions"
},
"basedOnDartAndFlutter": "Based on Dart SDK {dartVersion} and Flutter SDK {flutterVersion}",
"@basedOnDartAndFlutter": {
"description": "Based on Dart and Flutter title",
"placeholders": {
"dartVersion": {
"type": "String"
},
"flutterVersion": {
"type": "String"
}
}
},
"experimentsEnabled": "Experiments enabled: {experiments}",
"@experimentsEnabled": {
"description": "Experiments enabled",
"placeholders": {
"experiments": {
"type": "String"
}
}
},
"package": "Package",
"@package": {
"description": "Package table header"
},
"version": "Version",
"@version": {
"description": "Version table header"
},
"createNewSnippet": "Created new {type} snippet",
"@createNewSnippet": {
"description": "Create new snippet toast",
"placeholders": {
"type": {
"type": "String"
}
}
},
"codeCompletion": "Code completion",
"@codeCompletion": {
"description": "Code completion keyboard shortcut"
},
"find": "Find",
"@find": {
"description": "Find keyboard shortcut"
},
"findNext": "Find next",
"@findNext": {
"description": "Find next keyboard shortcut"
},
"quickFixes": "Quick fixes",
"@quickFixes": {
"description": "Quick fixes keyboard shortcut"
},
"reload": "Reload",
"@reload": {
"description": "Reload keyboard shortcut"
}
}
83 changes: 74 additions & 9 deletions pkgs/sketch_pad/lib/l10n/en.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Messages {
final Map<String, MessageList> _messages = {};

static const carbs = {
'en': ('lib/l10n/en.json', '/JmmZcLq'),
'de': ('lib/l10n/de.json', '8HMbX1u8')
'en': ('lib/l10n/en.json', 'GiyBDj/n'),
'de': ('lib/l10n/de.json', 'fhb5q58f')
};

IntlObject intlObject;
Expand Down Expand Up @@ -46,21 +46,86 @@ class Messages {
}

void loadAllLocales() {
for (final locale in knownLocales) {
for (var locale in knownLocales) {
loadLocale(locale);
}
}

String basedOnDartAndFlutter(
String dartVersion,
String flutterVersion,
) =>
_currentMessages.generateStringAtIndex(0, [dartVersion, flutterVersion]);

String channelSelection(String channelName) =>
_currentMessages.generateStringAtIndex(0, [channelName]);
_currentMessages.generateStringAtIndex(1, [channelName]);

String get clearConsole => _currentMessages.generateStringAtIndex(2, []);

String get codeCompletion => _currentMessages.generateStringAtIndex(3, []);

String get command => _currentMessages.generateStringAtIndex(4, []);

String get compilationFailed => _currentMessages.generateStringAtIndex(5, []);

String createNewSnippet(String type) =>
_currentMessages.generateStringAtIndex(6, [type]);

String get dartpadGithub => _currentMessages.generateStringAtIndex(7, []);

String get errorFormatting => _currentMessages.generateStringAtIndex(8, []);

String experimentsEnabled(String experiments) =>
_currentMessages.generateStringAtIndex(9, [experiments]);

String get feedback => _currentMessages.generateStringAtIndex(10, []);

String get find => _currentMessages.generateStringAtIndex(11, []);

String get findNext => _currentMessages.generateStringAtIndex(12, []);

String get format => _currentMessages.generateStringAtIndex(13, []);

String get formatSuccesful => _currentMessages.generateStringAtIndex(14, []);

String get installSdk => _currentMessages.generateStringAtIndex(15, []);

String get keyboardShortcut => _currentMessages.generateStringAtIndex(16, []);

String get keyboardShortcuts =>
_currentMessages.generateStringAtIndex(17, []);

String get newPad => _currentMessages.generateStringAtIndex(18, []);

String newSnippet(String type) =>
_currentMessages.generateStringAtIndex(19, [type]);

String get noFormattingChanges =>
_currentMessages.generateStringAtIndex(20, []);

String get package => _currentMessages.generateStringAtIndex(21, []);

String get privacyNotice => _currentMessages.generateStringAtIndex(22, []);

String get quickFixes => _currentMessages.generateStringAtIndex(23, []);

String get reload => _currentMessages.generateStringAtIndex(24, []);

String get runButton => _currentMessages.generateStringAtIndex(25, []);

String get runtimeVersions => _currentMessages.generateStringAtIndex(26, []);

String get feedback => _currentMessages.generateStringAtIndex(1, []);
String get samples => _currentMessages.generateStringAtIndex(27, []);

String get installSdk => _currentMessages.generateStringAtIndex(2, []);
String get sharingGuide => _currentMessages.generateStringAtIndex(28, []);

String get newPad => _currentMessages.generateStringAtIndex(3, []);
String switchedToDartAndFlutter(
String dartVersion,
String flutterVersion,
) =>
_currentMessages.generateStringAtIndex(29, [dartVersion, flutterVersion]);

String get privacyNotice => _currentMessages.generateStringAtIndex(4, []);
String get toggleBrightness => _currentMessages.generateStringAtIndex(30, []);

String get samples => _currentMessages.generateStringAtIndex(5, []);
String get version => _currentMessages.generateStringAtIndex(31, []);
}
2 changes: 1 addition & 1 deletion pkgs/sketch_pad/lib/l10n/en.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[0,"en","/JmmZcLq",0,null,[" channel",[0,0]],"Feedback","Install SDK","New","Privacy Notice","Samples"]
[0,"en","GiyBDj/n",0,null,["Based on Dart SDK and Flutter SDK ",[18,0],[35,1]],[" channel",[0,0]],"Clear console","Code completion","Command","Compilation failed",["Created new snippet",[12,0]],"DartPad on GitHub","Error formatting code",["Experiments enabled: ",[21,0]],"Feedback","Find","Find next","Format","Format successful","Install SDK","Keyboard shortcut","Keyboard shortcuts","New",["New snippet",[4,0]],"No formatting changes","Package","Privacy Notice","Quick fixes","Reload","Run","Runtime versions","Samples","Sharing Guide",["Switched to Dart and Flutter ",[17,0],[30,1]],"Toggle brightness","Version"]
Loading

0 comments on commit ba00e09

Please sign in to comment.