Cover image for blog post: "Add Somali (`so`) Localization to a Flutter App (Vendor `so.dart`)"
Back to blog posts

Add Somali (`so`) Localization to a Flutter App (Vendor `so.dart`)

How to enable Somali language in Flutter today by vendoring a custom Material localization (`so.dart`), wiring delegates, and avoiding common build pitfalls.

Published onAugust 10, 20255 minutes read

Table of Contents

Overview

Flutter doesn’t (yet) ship Somali (so) in the official flutter_localizations bundle. Until it lands upstream, you can vendor a single file (so.dart) that provides Somali strings for Material widgets and forwards Cupertino/Widgets to global fallbacks. This guide shows the exact setup used in the Masjid Abu Hureyra app.


Prerequisites

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: any # optional, recommended for date/time formatting

1) Add the Somali file

Create lib/l10n/so.dart and paste the final version below.

Important: The delegate must be a static const inside SoMaterialLocalizations. Do not use an extension to add a static delegate (Dart doesn’t allow static members in extensions).

// lib/l10n/so.dart
//
// One-stop Somali localization wiring for your app.
// - Material: Somali strings via SoMaterialLocalizations (your overrides)
// - Cupertino: temporarily forwards to GlobalCupertinoLocalizations (English/fallback)
// - Widgets:   forwards to GlobalWidgetsLocalizations (text direction etc.)
 
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
 
/// ------------------------------
///  MATERIAL (Somali overrides)
/// ------------------------------
class SoMaterialLocalizations extends MaterialLocalizations {
  // 

If your Flutter channel adds new abstract getters to MaterialLocalizations, the compiler will tell you which ones are missing — implement them in SoMaterialLocalizations with Somali (or temporary English).


2) Wire the delegates in MaterialApp

Make sure Somali delegates are listed before the global ones so they override.

import 'package:masjidabiihurayra/l10n/so.dart';
 
MaterialApp.router(
  // ...
  localizationsDelegates: const [
    AppLocalizations.delegate,          // your ARB-generated app strings
 
    SoMaterialLocalizations.delegate,   // 

3) (Optional) Initialize dates in Somali

If you format dates/times:

import 'package:intl/date_symbol_data_local.dart';
 
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await initializeDateFormatting('so');
  runApp(const ProviderScope(child: MyApp()));
}

4) Validate


5) Troubleshooting


6) Notes on Quality & Future Upstreaming


7) Minimal Example Snippet

final flutterSupportedLocales = const [
  Locale('en'),
  Locale('ar'),
  Locale('fr'),
  Locale('so'),
];
 
Locale? effectiveLocale(Locale? selected) {
  if (selected == null) return null;
  return flutterSupportedLocales.any((l) => l.languageCode == selected.languageCode)
      ? selected
      : const Locale('en');
}

8) License & Attribution

If you adapted strings from a public repo, check and keep the original LICENSE and add attribution in your repository. This blog post reflects a vendored approach for compatibility until official support ships.


Finish

With lib/l10n/so.dart in place and delegates registered, your Flutter app will show Somali UI for Material widgets today. If you hit a specific compile error after a Flutter upgrade, drop the error message in an issue and update SoMaterialLocalizations with any new required getters.