Dartvel, home
Docs
Features
Studio
Cloud
Compared

Search the site

GitHub
pub.dev

GETTING STARTED

Getting started
Existing Flutter apps
Existing Native apps
Run on your phone

APP

UI and styling
Routing
State
Accessibility
Keyboard shortcuts
Localization
Devices and desktop
Native device access
Media, 3D and XR

DATA

Data models
Forms
Search
Sync and offline
Import and export
Change capture
Database
Cache
File storage
Images
Privacy and erasure

BACKEND

Backend functions
Auth and sessions
Authorization
Queues and jobs
Workers and memory
Notifications and mail
Outbound HTTP
AI
Webhooks
GraphQL and OpenAPI
API keys and OAuth
Multi-tenancy
Billing and commerce
Modules

OPERATIONS

Edge security
Secrets and environments
Monitoring
Releases

SHIPPING

Build targets
Telegram Mini Apps
Static web hosting
Servers and deploying

REFERENCE

Testing
CLI reference
Coding agents

APP

Localization

Declare each string once as a typed key, and dartvel i18n tells you which languages are missing it.

Plurals follow the CLDR rules of each language.

ON THIS PAGE

Declare keys and load catalogues

Translate text and counts

Keep every language complete

Tell search engines about each language

Pick a language for a request

Status

Declare keys and load catalogues

class AppText {
  static const DVTranslationKey cartTitle = DVTranslationKey('cart.title');
  static const DVTranslationKey cartItems = DVTranslationKey('cart.items');
}

void loadTranslations() {
  DV.I18n.loadAll(const <DVTranslationCatalog>[
    DVTranslationCatalog(
      locale: LocaleTag.enUS,
      messages: <DVTranslationKey, String>{AppText.cartTitle: 'Your cart'},
      plurals: <DVTranslationKey, DVPluralForms>{
        AppText.cartItems: DVPluralForms(one: '{count} item', other: '{count} items'),
      },
    ),
    DVTranslationCatalog(
      locale: LocaleTag.frFR,
      messages: <DVTranslationKey, String>{AppText.cartTitle: 'Votre panier'},
      plurals: <DVTranslationKey, DVPluralForms>{
        AppText.cartItems: DVPluralForms(one: '{count} article', other: '{count} articles'),
      },
    ),
  ]);
}

Copy code to clipboard

A catalogue is const, with DVTranslationKey keys.

DVPluralForms takes zero, one, two, few, many and other, and the language decides which one a count uses.

Translate text and counts

DV.I18n.useLocale(LocaleTag.frFR);
final String title = DV.I18n.t(AppText.cartTitle); // Votre panier
final String count = DV.I18n.plural(AppText.cartItems, 3); // 3 articles

Copy code to clipboard

{name} placeholders are filled from args, and {count} from the count.

A missing key shows the key itself. Pass strict: true to throw instead.

DV.I18n.textDirection is rtl for Arabic, Hebrew, Persian and the other right-to-left languages.

Keep every language complete

dartvel i18n extract --locale en --locale fr
dartvel i18n check --strict

Copy code to clipboard

extract finds every DVTranslationKey under lib/ and writes lib/l10n/app_<locale>.arb, keeping translations you have.

check lists untranslated and no-longer-used keys per language. --strict fails, for CI.

Tell search engines about each language

# pubspec.yaml
dartvel:
  seo:
    siteUrl: https://example.com
  i18n:
    locales: [en, fr]
    defaultLocale: en

Copy code to clipboard

With two or more locales, dartvel build web writes hreflang links on every page: /about for the default and /fr/about for French, plus x-default.

Pick a language for a request

dvNegotiateLocale from dartvel_core chooses among your supported locales. A /fr/ path wins, then a stored preference, then Accept-Language, then the tenant's default, then your fallback.

Status

Built

Spec section: Internationalization and Localization

PREVIOUS Keyboard shortcuts Page and app shortcuts, safe typing and a shortcut sheet
NEXT Devices and desktop Native features, home widgets, kiosks, windows and trays
GitHub
pub.dev
npm
Acknowledgements
Privacy
Terms

FSL-1.1-MIT licensed. Built with Dartvel.

Dartvel is made by

SigmaDev Digital

To the bottom