Skip to content

Commit

Permalink
Added (draft) doc for mobile translations + added 2 new source string…
Browse files Browse the repository at this point in the history
…s for "add_participant_page"
  • Loading branch information
simondubrulle committed Nov 15, 2024
1 parent c94feb0 commit a88586c
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 2 deletions.
49 changes: 49 additions & 0 deletions mobile/docs/translations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Translations

We use Crowdin for translations, and the `intl` package to load these at
runtime.

Within our project we have the _source_ strings - these are the key value pairs
in the `lib/l10n/intl_en.arb` file.

Volunteers can add a new _translation_ in their language corresponding to each
such source key-value to our
[Crowdin project](https://crowdin.com/project/ente-photos-app).

When a new source string is added, we run a [GitHub workflow](../../.github/workflows/mobile-crowdin-push.yml)
that

- Uploads sources to Crowdin - So any new key value pair we add in the source
`intl_en.arb` becomes available to translators to translate.

Every monday, we run a [GitHub workflow](../../.github/workflows/mobile-crowdin-sync.yml)
that

- Downloads translations from Crowdin - So any new translations that
translators have made on the Crowdin dashboard (for existing sources) will
be added to the corresponding `intl_XX.arb`.

The workflow also uploads existing translations and also downloads new sources
from Crowdin, but these two should be no-ops.

## Adding a new string

- Add a new entry in `lib/l10n/intl_en.arb` (the
**source `intl_en.arb`**).
- Use the new key in code with the `S` class
(`import "package:photos/generated/l10n.dart"`).
- During the next sync, the workflow will upload this source item to Crowdin's
dashboard, allowing translators to translate it.

## Updating an existing string

- Update the existing value for the key in the source `intl_en.arb`.
- During the next sync, the workflow will clear out all the existing
translations so that they can be translated afresh.

## Deleting an existing string

- Remove the key value pair from the source `intl_en.arb`.
- During the next sync, the workflow will delete that source item from all
existing translations (both in the Crowdin project and also from the
other `intl_XX.arb` files in the repository).
26 changes: 26 additions & 0 deletions mobile/lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion mobile/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1363,5 +1363,25 @@
"checkingModels": "Checking models...",
"enableMachineLearningBanner": "Enable machine learning for magic search and face recognition",
"searchDiscoverEmptySection": "Images will be shown here once processing is complete",
"searchPersonsEmptySection": "People will be shown here once processing is complete"
"searchPersonsEmptySection": "People will be shown here once processing is complete",
"viewersSuccessfullyAdded": "{count, plural, =0 {Added 0 viewer} =1 {Added 1 viewer} other {Added {count} viewers}}",
"@viewersSuccessfullyAdded": {
"placeholders": {
"count": {
"type": "int",
"example": "2"
}
},
"description": "Number of viewers that were successfully added to an album."
},
"collaboratorsSuccessfullyAdded": "{count, plural, =0 {Added 0 collaborator} =1 {Added 1 collaborator} other {Added {count} collaborators}}",
"@collaboratorsSuccessfullyAdded": {
"placeholders": {
"count": {
"type": "int",
"example": "2"
}
},
"description": "Number of collaborators that were successfully added to an album."
}
}
2 changes: 1 addition & 1 deletion mobile/lib/ui/sharing/add_participant_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class _AddParticipantPage extends State<AddParticipantPage> {
results.where((e) => e).length;
showToast(
context,
"Added $noOfSuccessfullAdds ${widget.isAddingViewer ? "viewers" : "collaborators"}",
widget.isAddingViewer ? S.of(context).viewersSuccessfullyAdded(noOfSuccessfullAdds) : S.of(context).collaboratorsSuccessfullyAdded(noOfSuccessfullAdds),
);

if (!results.any((e) => e == false) && mounted) {
Expand Down

0 comments on commit a88586c

Please sign in to comment.