Skip to content

Commit

Permalink
Rename translation definition file
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed May 30, 2024
1 parent 9b1c8fe commit f643e3e
Show file tree
Hide file tree
Showing 27 changed files with 121 additions and 117 deletions.
30 changes: 15 additions & 15 deletions .github/actions/pre_build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ description: 'Internal Action for Tail App'
runs:
using: "composite"
steps:
- name: Configure Flutter CLI
shell: bash
run: flutter config --no-cli-animations --enable-analytics --color
- name: Enable Flutter tools
shell: bash
run: export TERM=xterm-color && dart pub global activate flutter_gen --color && dart pub global activate intl_translation --color && dart pub global activate build_runner --color
- name: Get dependencies
shell: bash
run: export TERM=xterm-color && flutter pub get --color
- name: Generate translation files
shell: bash
run: export TERM=xterm-color && dart pub global run --color intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/intn_defs.dart lib/l10n/*.arb
- name: Generate dart .g files
shell: bash
run: export TERM=xterm-color && dart pub global run --color build_runner build --delete-conflicting-outputs
- name: Configure Flutter CLI
shell: bash
run: flutter config --no-cli-animations --enable-analytics --color
- name: Enable Flutter tools
shell: bash
run: export TERM=xterm-color && dart pub global activate flutter_gen --color && dart pub global activate intl_translation --color && dart pub global activate build_runner --color
- name: Get dependencies
shell: bash
run: export TERM=xterm-color && flutter pub get --color
- name: Generate translation files
shell: bash
run: export TERM=xterm-color && dart pub global run --color intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/translation_string_definitions.dart lib/l10n/*.arb
- name: Generate dart .g files
shell: bash
run: export TERM=xterm-color && dart pub global run --color build_runner build --delete-conflicting-outputs
4 changes: 2 additions & 2 deletions .github/workflows/localization_strings_update.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
paths:
- 'lib/Frontend/intn_defs.dart'
- 'lib/Frontend/translation_string_definitions.dart'
jobs:
build_android:
name: Update Localization Files
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Install packages
run: flutter config --no-cli-animations && flutter pub get
- name: Generate intl_translation
run: dart pub global activate intl_translation && dart pub global run intl_translation:extract_to_arb --locale=en --output-file='./lib/l10n/messages_en.arb' ./lib/Frontend/intn_defs.dart
run: dart pub global activate intl_translation && dart pub global run intl_translation:extract_to_arb --locale=en --output-file='./lib/l10n/messages_en.arb' ./lib/Frontend/translation_string_definitions.dart
- name: Stage Changes
run: git config user.email "github-actions[bot]@users.noreply.github.com" && git config user.name "github-actions[bot]" && git commit -am "Update EN language file"
- name: Push changes
Expand Down
43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ Small or large, feel free to leave suggestions for new features, or changes to e
- [Git](https://git-scm.com/downloads)
- [Ruby](https://www.ruby-lang.org/en/) for FastLane

### Updating EN Localizations

To update EN localization strings, the file `[translation_string_definitions.dart](lib/Frontend/translation_string_definitions.dart)` needs to be updated.

```dart
String message() => Intl.message('Displayed Message', name: 'message', desc: 'A description of the string and where it is used');
```

The `Displayed Message` is the string that appears in the UI.
The `name` is the variable name. This must match the variable name used such as `message()` but without the `()`.
The `desc` is a description of the string for use by translators.

When `[translation_string_definitions.dart](lib/Frontend/translation_string_definitions.dart)` is updated, the job `[localization_strings_update.yml](.github/workflows/localization_strings_update.yml)` updates the generated localization file [messages_en.arb](lib/l10n/messages_en.arb) which makes the strings available to [Weblate](https://weblate.codel1417.xyz/projects/tail_app/tail_app/).
New Strings are auto translated by Google Translate but will not overwrite manually translated strings.

When non EN translations are updated in [Weblate](https://weblate.codel1417.xyz/projects/tail_app/tail_app/), A pull request will automatically open with the changes. This may take a few minutes.

### Building

#### Preparing for build
Expand All @@ -83,7 +100,7 @@ Small or large, feel free to leave suggestions for new features, or changes to e
> dart pub global activate intl_translation
>
> flutter pub get # Downloads Dependencies
> dart run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/intn_defs.dart lib/l10n/*.arb
> dart run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/translation_string_definitions.dart lib/l10n/*.arb
> flutter pub run build_runner build --delete-conflicting-outputs # Generates .g files
> ```
Expand All @@ -92,14 +109,14 @@ Small or large, feel free to leave suggestions for new features, or changes to e
>
> ```shell
> dart pub global activate intl_translation
> dart run intl_translation:extract_to_arb --locale=en --output-file='./lib/l10n/messages_en.arb' ./lib/Frontend/intn_defs.dart
> dart run intl_translation:extract_to_arb --locale=en --output-file='./lib/l10n/messages_en.arb' ./lib/Frontend/translation_string_definitions.dart
> ```
>
> To build localization files, run
>
> ```shell
> dart pub global activate intl_translation
> dart run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/intn_defs.dart lib/l10n/*.arb
> dart run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/translation_string_definitions.dart lib/l10n/*.arb
> ```
>
> To build generated `.g` files, run
Expand Down Expand Up @@ -216,27 +233,13 @@ Some of these values aren't actually secret and can be shared. Specifically the
#### Sentry
A github app which allows Sentry to authenticate with Github and this repo. It allows Source Code stack trace linking and Creating issues from the Sentry UI.
A github app which allows [Sentry](https://sentry.codel1417.xyz/organizations/sentry/projects/tail_app/?project=2) to authenticate with Github and this repo. It allows Source Code stack trace linking and Creating issues from the [Sentry](https://sentry.codel1417.xyz/organizations/sentry/projects/tail_app/?project=2) UI.
#### Weblate
A Webhook to notify Weblate that code was pushed to this repo.
A SSH key is installed in my account which allows weblate to push translation changes to the repo.
### Updating EN Localizations
To update EN localization strings, the file [intn_defs.dart](lib/Frontend/intn_defs.dart) needs to be updated.
```dart
String message() => Intl.message('Displayed Message', name: 'message', desc: 'A description of the string and where it is used');
```
The `Displayed Message` is the string that appears in the UI.
The `name` is the variable name. This must match the variable name used such as `message()` but without the `()`.
The `desc` is a description of the string for use by translators.
A Webhook to notify [Weblate](https://weblate.codel1417.xyz/projects/tail_app/tail_app/) that code was pushed to this repo.
When [intn_defs.dart](lib/Frontend/intn_defs.dart) is updated, the job [localization_strings_update.yml](.github/workflows/localization_strings_update.yml) updates the generated localization file [messages_en.arb](lib/l10n/messages_en.arb) which makes the strings available to [Weblate](https://weblate.codel1417.xyz/projects/tail_app/tail_app/).
A SSH key is installed in my account which allows [Weblate](https://weblate.codel1417.xyz/projects/tail_app/tail_app/) to push translation changes to the repo.
### Developer Mode Features
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/Definitions/Action/base_action.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:hive/hive.dart';
import 'package:tail_app/Frontend/intn_defs.dart';
import 'package:tail_app/Frontend/translation_string_definitions.dart';
import 'package:uuid/uuid.dart';

import '../Device/device_definition.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/Definitions/Device/device_definition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:tail_app/Backend/Bluetooth/bluetooth_manager.dart';
import 'package:tail_app/Backend/Bluetooth/bluetooth_manager_plus.dart';
import 'package:tail_app/Backend/firmware_update.dart';

import '../../../Frontend/intn_defs.dart';
import '../../../Frontend/translation_string_definitions.dart';
import '../../../Frontend/utils.dart';
import '../../Bluetooth/bluetooth_message.dart';

Expand Down
8 changes: 2 additions & 6 deletions lib/Backend/move_lists.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import 'package:audio_session/audio_session.dart';
import 'package:chart_sparkline/chart_sparkline.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:just_audio/just_audio.dart';
import 'package:logging/logging.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:sentry_hive/sentry_hive.dart';
import 'package:tail_app/Backend/Bluetooth/bluetooth_message.dart';
import 'package:tail_app/Backend/Definitions/Action/base_action.dart';
import 'package:tail_app/Backend/Definitions/Device/device_definition.dart';
import 'package:tail_app/Backend/audio.dart';
import 'package:tail_app/Frontend/intn_defs.dart';
import 'package:tail_app/Frontend/translation_string_definitions.dart';

import '../main.dart';

Expand Down Expand Up @@ -257,12 +255,10 @@ Future<void> runAction(BaseAction action, BaseStatefulDevice device) async {
}
}
}
}
else if (action is AudioAction){
} else if (action is AudioAction) {
String file = action.file;

playSound(file);

}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/sensors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import 'package:tail_app/Backend/Bluetooth/bluetooth_manager_plus.dart';
import 'package:tail_app/Backend/Bluetooth/bluetooth_message.dart';
import 'package:tail_app/Backend/action_registry.dart';

import '../Frontend/intn_defs.dart';
import '../Frontend/translation_string_definitions.dart';
import '../constants.dart';
import 'Bluetooth/bluetooth_manager.dart';
import 'Definitions/Action/base_action.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/Widgets/back_button_to_close.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../Backend/Bluetooth/bluetooth_manager_plus.dart';
import '../intn_defs.dart';
import '../translation_string_definitions.dart';

class BackButtonToClose extends ConsumerStatefulWidget {
const BackButtonToClose({required this.child, super.key});
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/Widgets/device_type_widget.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';

import '../../Backend/Definitions/Device/device_definition.dart';
import '../intn_defs.dart';
import '../translation_string_definitions.dart';

class DeviceTypeWidget extends StatelessWidget {
const DeviceTypeWidget({super.key, required this.selected, required this.onSelectionChanged});
Expand Down
105 changes: 55 additions & 50 deletions lib/Frontend/Widgets/known_gear.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'package:tail_app/Frontend/Widgets/scan_for_new_device.dart';
import '../../Backend/Bluetooth/bluetooth_manager.dart';
import '../../constants.dart';
import '../../main.dart';
import '../intn_defs.dart';
import '../pages/shell.dart';
import '../translation_string_definitions.dart';

class KnownGear extends ConsumerStatefulWidget {
const KnownGear({super.key});
Expand Down Expand Up @@ -40,60 +40,65 @@ class ScanForNewGearButton extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
return TweenAnimationBuilder(tween: ref.watch(knownDevicesProvider).isEmpty ? Tween<double>(begin: 0, end: 1) : Tween<double>(begin: 1, end: 0), duration: animationTransitionDuration, builder: (context, value, child) {
return Card(
clipBehavior: Clip.antiAlias,
color: Color.lerp(Theme.of(context).cardColor, Theme.of(context).primaryColor, value),
child:child ,
);
},child: InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: 50 * MediaQuery.textScalerOf(context).scale(1),
width: ref.watch(knownDevicesProvider).values.length > 1 ? 100 * MediaQuery.textScalerOf(context).scale(1) : 200 * MediaQuery.textScalerOf(context).scale(1),
child: Center(
child: Text(
scanDevicesTitle(),
textAlign: TextAlign.center,
return TweenAnimationBuilder(
tween: ref.watch(knownDevicesProvider).isEmpty ? Tween<double>(begin: 0, end: 1) : Tween<double>(begin: 1, end: 0),
duration: animationTransitionDuration,
builder: (context, value, child) {
return Card(
clipBehavior: Clip.antiAlias,
color: Color.lerp(Theme.of(context).cardColor, Theme.of(context).primaryColor, value),
child: child,
);
},
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: 50 * MediaQuery.textScalerOf(context).scale(1),
width: ref.watch(knownDevicesProvider).values.length > 1 ? 100 * MediaQuery.textScalerOf(context).scale(1) : 200 * MediaQuery.textScalerOf(context).scale(1),
child: Center(
child: Text(
scanDevicesTitle(),
textAlign: TextAlign.center,
),
),
),
),
),
onTap: () {
plausible.event(page: "Scan For New Gear");
showModalBottomSheet(
context: context,
showDragHandle: true,
isScrollControlled: true,
enableDrag: true,
isDismissible: true,
builder: (BuildContext context) {
return DraggableScrollableSheet(
initialChildSize: 0.5,
expand: false,
builder: (BuildContext context, ScrollController scrollController) {
return Column(
children: [
ListTile(
title: Text(
scanDevicesTitle(),
style: Theme.of(context).textTheme.titleLarge,
onTap: () {
plausible.event(page: "Scan For New Gear");
showModalBottomSheet(
context: context,
showDragHandle: true,
isScrollControlled: true,
enableDrag: true,
isDismissible: true,
builder: (BuildContext context) {
return DraggableScrollableSheet(
initialChildSize: 0.5,
expand: false,
builder: (BuildContext context, ScrollController scrollController) {
return Column(
children: [
ListTile(
title: Text(
scanDevicesTitle(),
style: Theme.of(context).textTheme.titleLarge,
),
),
),
Expanded(
child: ScanForNewDevice(
scrollController: scrollController,
Expanded(
child: ScanForNewDevice(
scrollController: scrollController,
),
),
),
],
);
},
);
},
);
},
),);
],
);
},
);
},
);
},
),
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/Widgets/scan_for_new_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import '../../Backend/device_registry.dart';
import '../../constants.dart';
import '../../gen/assets.gen.dart';
import '../../main.dart';
import '../intn_defs.dart';
import '../translation_string_definitions.dart';
import 'lottie_lazy_load.dart';

class ScanForNewDevice extends ConsumerStatefulWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/Widgets/speed_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

import '../intn_defs.dart';
import '../translation_string_definitions.dart';

class SpeedWidget extends StatelessWidget {
const SpeedWidget({super.key, required this.value, required this.onChanged});
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/Widgets/trigger_select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../Backend/sensors.dart';
import '../intn_defs.dart';
import '../translation_string_definitions.dart';

class TriggerSelect extends ConsumerStatefulWidget {
const TriggerSelect({super.key});
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/pages/action_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:tail_app/constants.dart';
import '../../Backend/Definitions/Action/base_action.dart';
import '../../Backend/Definitions/Device/device_definition.dart';
import '../../Backend/action_registry.dart';
import '../intn_defs.dart';
import '../translation_string_definitions.dart';

class ActionSelectorInfo {
final Set<DeviceType> deviceType;
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/pages/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import '../../Backend/device_registry.dart';
import '../../Backend/move_lists.dart';
import '../../constants.dart';
import '../Widgets/tutorial_card.dart';
import '../intn_defs.dart';
import '../translation_string_definitions.dart';
import 'home.dart';

class ActionPage extends ConsumerWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/pages/custom_audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:tail_app/Backend/audio.dart';
import 'package:uuid/uuid.dart';

import '../Widgets/tutorial_card.dart';
import '../intn_defs.dart';
import '../translation_string_definitions.dart';

final Logger _audioLogger = Logger('Audio');

Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/pages/direct_gear_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import '../../Backend/Definitions/Device/device_definition.dart';
import '../../Backend/move_lists.dart';
import '../../constants.dart';
import '../Widgets/device_type_widget.dart';
import '../intn_defs.dart';
import '../translation_string_definitions.dart';

class DirectGearControl extends ConsumerStatefulWidget {
const DirectGearControl({super.key});
Expand Down
Loading

0 comments on commit f643e3e

Please sign in to comment.