Main menu

12 Feb 2024

Multiple fallback locales

The Export API "fallback" parameter now supports multiple language tags separated by commas. For example, exporting a regional German file (de-AT) you could specify a base German locale (de) and a final default (en) like this: /api/export/locale/de-AT.json?fallback=de,en

Auto fallback

As a shortcut for the above, you can specify fallback=auto. This applies a simple truncation algorithm to the language tag, and then appends the project source locale. For example, exporting de-AT would yield the same result as above (assuming your source language is English and the German base language exists in your project).

Custom fallback

The truncation algorithm is only useful when there are common language tags. (de being a super set of de-AT). To handle other cases, this behaviour can be overridden in your locale settings (developer tab) as shown below. This example shows that Haitian (ht) will fallback to French (fr) before finally English.

img

Note that fallback=auto must still be specified to use the custom fallback. Default behaviour is no fallback for backward compatibility.

Change to plural fallbacks

This is a bug fix, but if you've been relying on incorrect behaviour then this is a breaking change.

When an untranslated plural form falls back to another language, Loco now uses the most appropriate form in the fallback language while maintaining the target language's plural rules.

Previous behaviour was to use the plural rules of the fallback language, which in some cases would produce strange results due to differing plural offsets. This is best illustrated with an example:

Arabic "one" is the second plural form (at offset 1) whereas English "one" is the first (at offset 0). The export API now remaps these positions, so the "one" form is maintained. Forms that are absent in the fallback language (like "zero") will default to "other".

Last updated by