Skip to content

Add "fallbackLanguage" to piral-translate#806

Merged
FlorianRappl merged 1 commit intodevelopfrom
feature/fallback-language
Feb 25, 2026
Merged

Add "fallbackLanguage" to piral-translate#806
FlorianRappl merged 1 commit intodevelopfrom
feature/fallback-language

Conversation

@manuelroemer
Copy link
Member

New Pull Request

For more information, see the CONTRIBUTING guide.

Prerequisites

Please make sure you can check the following boxes:

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project
  • All new and existing tests passed

Type(s) of Changes

Contribution Type

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue, please reference the issue id)
  • New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • I have updated the documentation accordingly
  • I have added tests to cover my changes

Description

Adds a new fallbackLanguage to piral-translate which allows configuring a default language to be used for translations prior to the default fallback function.

The goal of this PR is to allow translate API users to always show a translation with a conventional default language (e.g., english) that is always known to be available, even if the user's desired language is not yet implemented in a pilet.
Currently, with the default fallback, this is not (easily) possible because custom fallback functions do not have access to the Localizer's internal API or the formatMessage function.

Remarks

In principle, this PR is a suggestion - I am sure that there are other ways of implementing this. I am open to suggestions, this PR is just, in my eyes, the most straightforward way to do this.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Manuel Römer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link

File size impact

Impact on file sizes when merging feature/fallback-language into develop.

empty-piral (no impact)
Files new size
Unmodified (2) 30.4 kB (0 B / +0%) 👻
Total (2) 30.4 kB (0 B / +0%) 👻
minimal-piral (no impact)
Files new size
Unmodified (2) 280 kB (0 B / +0%) 👻
Total (2) 280 kB (0 B / +0%) 👻
sample-cross-fx (no impact)
Files new size
Unmodified (3) 2.2 MB (0 B / +0%) 👻
Total (3) 2.2 MB (0 B / +0%) 👻
sample-piral (+0.03%)
Files new size
…/samples/sample-piral/dist/release/index.cf29f2.js 528 kB 👶
…/samples/sample-piral/dist/release/main.93c1c5.css 171 kB 👶
…/samples/sample-piral/dist/release/main.960ccc.css deleted (-171 kB)
…/samples/sample-piral/dist/release/index.97925c.js deleted (-528 kB)
src/samples/sample-piral/dist/release/index.html 490 B (0 B / +0%) 👻
Total (5) 700 kB (+186 B / +0.03%) ↗️
sample-piral-core (no impact)
Files new size
Unmodified (3) 357 kB (0 B / +0%) 👻
Total (3) 357 kB (0 B / +0%) 👻
Generated by @jsenv/file-size-impact during check-bundle-size#22401032677 on 9dbe975

Copy link
Contributor

@FlorianRappl FlorianRappl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@FlorianRappl FlorianRappl added this to the 1.10.1 milestone Feb 25, 2026
@FlorianRappl FlorianRappl added enhancement New feature or request plugin Covered by an opt-in plugin for Piral. labels Feb 25, 2026
@FlorianRappl FlorianRappl merged commit b2bfd5c into develop Feb 25, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request plugin Covered by an opt-in plugin for Piral.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants