搜尋套件、儲存庫與 APP 分類

GitHub 儲存庫VeryGoodOpenSource/r13n

r13n

Flutter 的區域化支援。由 Very Good Ventures 🦄 開發

r13n 專案封面
星標
77
分支
4
最近推送(UTC)
2026年3月6日
專案狀態
已封存

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

🌐 r13n

Deprecated: This repository has been archived and is no longer maintained. The r13n package has been discontinued on pub.dev and the r13n brick has been discontinued on BrickHub. There will be no further updates, bug fixes, or official support from Very Good Ventures.

If you need to continue development, you are welcome to fork this repository.

Very Good Ventures Very Good Ventures

ci coverage style: very good analysis License: MIT Powered by Mason


A Flutter package that makes regionalization easy. Heavily inspired by flutter_localizations and intl.

Similar to l10n which is short for localization, this package is called r13n as shorthand for regionalization.

Developed with 💙 by Very Good Ventures 🦄

What is regionalization? 📍

Regionalization helps you display text in the app based on a person's region.

Example: Say your app’s users are in the US and the UK. On your support page, you want to display the correct support email based on the user’s region. You can use the r13n package to display support.uk@mycompany.com to users in the UK and support.us@mycompany.com to users in the US.

Similarly, l10n helps you display translations based on the user’s locale.

Example: When using l10n, your app will display text in the user’s preferred language.

The r13n package can and should be used in conjunction with l10n. r13n is an additional mechanism to personalize information presented to users in an app.

How it works ⚙️

Similar to l10n, the r13n package uses .arb files to house the region-specific configurations.

The arb file contains strings for region-specific values. The r13n brick is used to generate compile-safe Dart code in order to access the correct versions of each value based on the user's region.

Quick Start 🚀

  1. For each supported region, add a new .arb file in lib/r13n/arb.
├── r13n
│   ├── arb
│   │   ├── app_gb.arb
│   │   └── app_us.arb
  1. Add the translated strings to each .arb file:

app_us.arb

{
    "@@region": "us",
    "supportEmail": "us@verygood.ventures"
}

app_gb.arb

{
    "@@region": "gb",
    "supportEmail": "gb@verygood.ventures"
}
  1. If you don't already have mason_cli, use the following command:
$ dart pub global activate mason_cli
  1. Then, install the r13n brick globally.
$ mason add r13n -g
  1. Add a new yaml file to the root directory of the Flutter project called r13n.yaml with the following content:
arb-dir: lib/r13n/arb
template-arb-file: app_us.arb
  1. Generate files.
$ mason make r13n --on-conflict overwrite
├── r13n
│   ├── arb
│   │   ├── gen
│   │   │   ├── app_regionalizations_gb.g.dart
│   │   │   ├── app_regionalizations_us.g.dart
│   │   │   └── app_regionalizations.g.dart
│   │   ├── app_us.arb
│   │   └── app_gb.arb
  1. Add a Regionalizations widget to the widget tree.
class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Regionalizations(
      region: Region.fromPlatform(),
      delegates: const [AppRegionalizations.delegate],
      child: MaterialApp(...)
      ...
    );
  1. Use the new string.
import 'package:example/r13n/r13n.dart';

@override
Widget build(BuildContext context) {
  final r13n = AppRegionalizations.of(context);
  return Text(r13n.supportEmail);
}

Roadmap 🗺

Note: This roadmap will not be pursued. The package is discontinued and this repository is archived.

  • [ ] Support asynchronous delegates
  • [ ] Support regionalization based on IP address
  • [ ] Provide API's to support sub-regions (for example, states in the U.S.)

Additional Resources 📚

For more information, see the example, the r13n brick and the source code.

Very Good Open Source GitHub avatar
GitHub 作者

Very Good Open Source ↗

Open source code from Very Good Ventures (@VGVentures)

New York, NY官方網站 ↗
語言DartC++CMakeShellHTMLCSwiftKotlinObjective-C

分類

使用的依賴

依賴清單 3 項

  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}
  • very_good_analysis開發依賴^7.0.0

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗