@@ -2,6 +2,7 @@ import 'dart:async';
22import 'dart:convert' ;
33import 'dart:io' ;
44import 'dart:ui' show FlutterView;
5+ import 'package:flutter/cupertino.dart' show CupertinoLocalizations;
56import 'package:flutter/foundation.dart' show kIsWeb;
67import 'package:flutter/material.dart' ;
78import 'package:flutter_localizations/flutter_localizations.dart' ;
@@ -245,6 +246,41 @@ class _StartupRecoveryResult {
245246 });
246247}
247248
249+ /// Provides Material localizations for the [och] language code by proxying
250+ /// to Simplified Chinese, since [GlobalMaterialLocalizations] does not support
251+ /// ISO 639-3 codes like [och] .
252+ class _OchMaterialLocalizationsDelegate
253+ extends LocalizationsDelegate <MaterialLocalizations > {
254+ const _OchMaterialLocalizationsDelegate ();
255+
256+ @override
257+ bool isSupported (Locale locale) => locale.languageCode == 'och' ;
258+
259+ @override
260+ Future <MaterialLocalizations > load (Locale locale) =>
261+ GlobalMaterialLocalizations .delegate.load (const Locale ('zh' ));
262+
263+ @override
264+ bool shouldReload (_OchMaterialLocalizationsDelegate old) => false ;
265+ }
266+
267+ /// Provides Cupertino localizations for the [och] language code by proxying
268+ /// to Simplified Chinese, for the same reason as [_OchMaterialLocalizationsDelegate] .
269+ class _OchCupertinoLocalizationsDelegate
270+ extends LocalizationsDelegate <CupertinoLocalizations > {
271+ const _OchCupertinoLocalizationsDelegate ();
272+
273+ @override
274+ bool isSupported (Locale locale) => locale.languageCode == 'och' ;
275+
276+ @override
277+ Future <CupertinoLocalizations > load (Locale locale) =>
278+ GlobalCupertinoLocalizations .delegate.load (const Locale ('zh' ));
279+
280+ @override
281+ bool shouldReload (_OchCupertinoLocalizationsDelegate old) => false ;
282+ }
283+
248284class TouchFishApp extends StatefulWidget {
249285 final bool isFirstLaunch;
250286 final bool hasSavedSession;
@@ -499,10 +535,12 @@ class _TouchFishAppState extends State<TouchFishApp> {
499535
500536 return MaterialApp .router (
501537 routerConfig: _router,
502- onGenerateTitle: (context) => AppLocalizations .of (context)! .appName,
538+ onGenerateTitle: (context) => AppLocalizations .of (context)? .appName ?? '' ,
503539 debugShowCheckedModeBanner: false ,
504540 localizationsDelegates: const [
505541 AppLocalizations .delegate,
542+ _OchMaterialLocalizationsDelegate (),
543+ _OchCupertinoLocalizationsDelegate (),
506544 GlobalMaterialLocalizations .delegate,
507545 GlobalWidgetsLocalizations .delegate,
508546 GlobalCupertinoLocalizations .delegate,
0 commit comments