Is there any library for Sinhala language in flutter localization?

225 views
Skip to first unread message

Yasas Sandeepa

unread,
Aug 16, 2019, 10:14:44 AM8/16/19
to Flutter Development (flutter-dev)

I’m developing a mobile application using flutter to be used in my country, Sri Lanka. I have to use Sinhala language as the font in the mobile UIs. I searched it on many websites, went through documentations  but unable to find a proper solution. I want to know whether there is a flutter_localization library that can be used in my application or any other solution to this. Thanks in advance.

EthicCoders Apps

unread,
Aug 16, 2019, 10:40:31 AM8/16/19
to Yasas Sandeepa, Flutter Development (flutter-dev)
I would be loading a new font (Sinhala font in our case) and use it in the app...  Here is what we do for our regional language app:
  1. Drop your font in the app to this path: /assets/fonts/xxx.ttf  (You need to create assets/font folder in your app)
  2. Define it in the pubspec.yaml like:
    • fonts:
      - family: xxx
      fonts:
      - asset: assets/fonts/xxx.ttf
  3.  Then attach it to the text widget where you want to use the said font:
    • Text(title, style: TextStyle(fontFamily: "xxx", fontWeight: FontWeight.bold),));

Hope this helps... if you need a full working sample app let me know can send over the code... 




On Fri, Aug 16, 2019 at 7:44 PM Yasas Sandeepa <yasassan...@gmail.com> wrote:

I’m developing a mobile application using flutter to be used in my country, Sri Lanka. I have to use Sinhala language as the font in the mobile UIs. I searched it on many websites, went through documentations  but unable to find a proper solution. I want to know whether there is a flutter_localization library that can be used in my application or any other solution to this. Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/9487cf7c-5500-497d-a52d-c27320b8d20c%40googlegroups.com.

Yasas Sandeepa

unread,
Aug 16, 2019, 10:41:54 PM8/16/19
to Flutter Development (flutter-dev)
Thank you very much for your kind attention. But I also need English as secondary language. In this method, I have to hardcode each and every value and it is way more difficult to handle with a isSelect boolean variable. (Also I cannot implement it with API requests..Is there a way to translate it?) Can you please provide a convenient way..!! Thanks in advance.

On Friday, August 16, 2019 at 8:10:31 PM UTC+5:30, EthicCoders Apps wrote:
I would be loading a new font (Sinhala font in our case) and use it in the app...  Here is what we do for our regional language app:
  1. Drop your font in the app to this path: /assets/fonts/xxx.ttf  (You need to create assets/font folder in your app)
  2. Define it in the pubspec.yaml like:
    • fonts:
      - family: xxx
      fonts:
      - asset: assets/fonts/xxx.ttf
  3.  Then attach it to the text widget where you want to use the said font:
    • Text(title, style: TextStyle(fontFamily: "xxx", fontWeight: FontWeight.bold),));

Hope this helps... if you need a full working sample app let me know can send over the code... 




On Fri, Aug 16, 2019 at 7:44 PM Yasas Sandeepa <yasassan...@gmail.com> wrote:

I’m developing a mobile application using flutter to be used in my country, Sri Lanka. I have to use Sinhala language as the font in the mobile UIs. I searched it on many websites, went through documentations  but unable to find a proper solution. I want to know whether there is a flutter_localization library that can be used in my application or any other solution to this. Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.

EthicCoders Apps

unread,
Aug 17, 2019, 6:41:31 AM8/17/19
to Yasas Sandeepa, Flutter Development (flutter-dev)
If you need dual language support... then we take this approach:
  1. Define a app_theme.dart class...  in that all the app theme related stuff we handle - like theme_data, color, font style, font size, day or night mode, etc... 
  2. In that the selected font loading part is handled like: 
    • class AppTheme {
    • ....
    • static bodyTextStyle(BuildContext context) {
      String fontFamily = Provider.of<AppSettingsProvider>(context).isEnglishLang() ? "Helvetica": "thiruvachanam" ;
      return new TextStyle(fontSize: 16.0, fontFamily: fontFamily);
      }
    • }
  3. Then for any TextWidget, from anywhere in the app just set the style object like...
    • @override
      Widget build(BuildContext context) {
      ...
      ....
      return Text(verseString, style: AppTheme.bodyTextStyle(context),);
      }
This should help you in getting the dual language support done...
NB: On a side note we use Provider state management to persist the language selection... To use provider is altogether a different topic on how to persist/save AppSettings... but for now you can just replace that call with a simple bool var isEnglish.


To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/fe12e6cd-8b7f-4838-a579-63149264b7f6%40googlegroups.com.

Yasas Sandeepa

unread,
Aug 17, 2019, 9:43:18 AM8/17/19
to Flutter Development (flutter-dev)
Oh. It's awesome..!! You made my day. Thank you so much for your great help.It means a lot to me..!!
Reply all
Reply to author
Forward
0 new messages