Skip to content

Instantly share code, notes, and snippets.

@tianhaoz95
tianhaoz95 / generate.sh
Last active March 19, 2020 04:42
generate wrappers
flutter pub run intl_translation:extract_to_arb --output-dir=i18n/messages i18n.dart
# After this, 1 arb file will be generated per locale in i18n/messages
@tianhaoz95
tianhaoz95 / example.json
Created March 19, 2020 04:38
translation
// for intl_zh.arb
"awesomeNewMessage": "一条新信息",
"@awesomeNewMessage": {
"description": "新信息例子",
"type": "text"
}
// for intl_en.arb
"awesomeNewMessage": "An awesome new message",
"@awesomeNewMessage": {
"description": "Example for how to add a new message",
@tianhaoz95
tianhaoz95 / generate_dart.sh
Created March 19, 2020 04:41
example for generating dart code from arb translations
flutter pub run intl_translation:generate_from_arb --output-dir=i18n/wrappers i18n.dart i18n/messages/*.arb
# After this more wrapper dart code will be generated in the wrappers directory
@tianhaoz95
tianhaoz95 / message_getter_example.dart
Created March 19, 2020 04:44
example i18n message getter
String get title {
return Intl.message(
'Mini Donkey',
name: 'title',
desc: 'Title for the application',
locale: localeName,
);
}
@tianhaoz95
tianhaoz95 / app.dart
Created March 19, 2020 05:35
example app with i18n
class PhotoChatApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<AppContext>(
create: (context) =>
AppContext(appRunningStateOverride: this.appRunningState),
child: MaterialApp(
title: 'Mini Donkey',
localizationsDelegates: [
AppLocalizationsDelegate(),
@tianhaoz95
tianhaoz95 / home.dart
Created March 19, 2020 05:43
example of using i18n
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).title),
),
);
}
}
@tianhaoz95
tianhaoz95 / fastfile.ruby
Created March 30, 2020 06:07
script to do android release
default_platform(:android)
platform :android do
lane :internal do
gradle(task: 'bundle', build_type: 'Release')
upload_to_play_store(track: 'internal', aab: 'path/to/your/app.aab')
end
lane :alpha do
gradle(task: 'bundle', build_type: 'Release')
upload_to_play_store(track: 'internal', track_promote_to: 'alpha')
end
@tianhaoz95
tianhaoz95 / trigger_release.yml
Created March 31, 2020 01:09
The workflow config to trigger a app release on push and release events
name: release android app
on:
release:
types:
- "published"
- "prereleased"
push:
branches:
- "master"
@tianhaoz95
tianhaoz95 / push_hook_actions.yml
Created March 31, 2020 02:13
release to internal and alpha with push
jobs:
release-android:
name: release android app
runs-on: ubuntu-latest
steps:
- ...
- name: release app to internal track
if: contains(github.event_name,'push')
run: bundle exec fastlane internal
- name: promote to alpha track
jobs:
release-android:
name: release android app
runs-on: ubuntu-latest
steps:
- ...
- name: promote to beta track
if: contains(github.event_name,'release')&&(github.event.release.prerelease)
run: bundle exec fastlane beta
- ...