{"id":2944,"date":"2022-05-18T13:59:36","date_gmt":"2022-05-18T11:59:36","guid":{"rendered":"https:\/\/itell.solutions\/?p=2944"},"modified":"2022-09-15T11:27:59","modified_gmt":"2022-09-15T09:27:59","slug":"elementor-2944","status":"publish","type":"post","link":"https:\/\/itell.solutions\/en\/elementor-2944\/","title":{"rendered":"Simple and easy internationalization with Flutter"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"2944\" class=\"elementor elementor-2944\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b4a2056 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b4a2056\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-28a0f46\" data-id=\"28a0f46\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b67a165 elementor-widget elementor-widget-text-editor\" data-id=\"b67a165\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><\/p>\n<div>\n<div>\n<h2>General<\/h2>\n<\/div>\n<div>Internationalization is an important part in the process of developing modern apps. It is absolutely necessary when you develop a multi-language app but it is also a <strong>good practice<\/strong> to prepare your app for proper internationalization even though you support only one language at the moment.<\/div>\n<div>\u00a0<\/div>\n<div>I<strong>n general, internationalization is the process of designing and architecting your source code in a way that makes it easy to localize.<\/strong> The target is to structure your application so that it can be adapted for other languages or regions without having to change major parts of your source code. <strong>By translating text or adding locale-specific date formatting you are performing a localization of your internationalized application.<\/strong><\/div>\n<div>\u00a0<\/div>\n<div>Translation of strings is only one aspect of localization but it might be the first obvious thing to do if you prepare your app for multiple languages.<\/div>\n<div>\u00a0<\/div>\n<div>There are major advantages using the principles, patterns and structures of proper internationalization in a single-language-app but it boils down to one significant point: <strong>retrieving any language-specific, hardcoded strings from source code by inserting another level of abstraction.<\/strong><\/div>\n<div>\u00a0<\/div>\n<div>The target is to replace all strings with placeholders and move the strings to separate Files (for example *.arb or *.po-Files). These files are saved in a human-readable format and can be viewed in a text editor by developers and translators.<\/div>\n<div>\u00a0<\/div>\n<\/div>\n<h2>Internationalization with Flutter<\/h2>\n<div>\n<div><strong>The good news is:<\/strong> internationalization in Flutter is possible and well supported.<\/div>\n<div><strong>The bad news is:<\/strong> if you are doing it from scratch it is rather complex and it takes some time to get your head around it.<\/div>\n<div>Even with the help of the packages flutter_localizations and intl it is quite complex because you have to create arb-Files at the right place, implement delegates and so on\u2026<\/div>\n<div>\u00a0<\/div>\n<\/div>\n<h2>The solution<\/h2>\n<div>\n<div>\n<div>If you are developing your Flutter-application with Android Studio then internationalization becomes<strong> VERY easy.<\/strong><\/div>\n<div>There is a plugin for <strong>Android Studio<\/strong> which is called <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/13666-flutter-intl\" target=\"_blank\" rel=\"noopener\"><em><strong>flutter_intl<\/strong><\/em><\/a> which is easy to use and creates all the boilderplate-code that is necessary for proper internationalization.<\/div>\n<\/div>\n<\/div>\n<p dir=\"ltr\" style=\"line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;\"><span style=\"color: var( --e-global-color-text ); font-family: var( --e-global-typography-text-font-family ), Sans-serif; font-weight: var( --e-global-typography-text-font-weight ); letter-spacing: 0px;\">\u00a0<\/span><\/p>\n<h4><span style=\"color: var( --e-global-color-text ); font-family: var( --e-global-typography-text-font-family ), Sans-serif; font-weight: var( --e-global-typography-text-font-weight ); letter-spacing: 0px;\">1. Install flutter_intl in Android Studio<\/span><\/h4>\n<p><\/p>\n<p><\/p>\n<p><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a17adb8 elementor-widget elementor-widget-image\" data-id=\"a17adb8\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"800\" height=\"580\" src=\"https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/plugin-1024x742.png\" class=\"attachment-large size-large wp-image-2950\" alt=\"\" srcset=\"https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/plugin-1024x742.png 1024w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/plugin-300x217.png 300w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/plugin-768x556.png 768w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/plugin-18x12.png 18w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/plugin.png 1042w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\"><\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1f8d54c elementor-widget elementor-widget-text-editor\" data-id=\"1f8d54c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div><h4>2. Initialize plugin<\/h4><div>First open your project and then initialize the plugin by running the \u201cI<strong>nitialize for the Project<\/strong>\u201d command from Tools &#8211; Flutter Intl menu.<\/div><div>The plugin creates a file lib\/l10n\/intl_en.arb which is used for the default locale \u201cen\u201d.<\/div><div><em>Files inside the newly generated folder lib\/generated\/ should not be edited.<\/em><\/div><\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e55c927 elementor-widget elementor-widget-image\" data-id=\"e55c927\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"634\" height=\"500\" src=\"https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/intl_menu.png\" class=\"attachment-large size-large wp-image-2949\" alt=\"\" srcset=\"https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/intl_menu.png 634w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/intl_menu-300x237.png 300w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/intl_menu-15x12.png 15w\" sizes=\"(max-width: 634px) 100vw, 634px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1822749 elementor-widget elementor-widget-text-editor\" data-id=\"1822749\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3>3. Add locale for german<\/h3>\n<div>Select Tools &#8211; Flutter Intl &#8211; Add locale and enter the name of the new locale. In this case \u201cde\u201d. The command then creates a new file: <em>lib\/l10n\/.arb<\/em><\/div>\n<div>\u00a0<\/div>\n<h4>4. Code integration<\/h4>\n<div>Add dependencies:<\/div>\n<div>\n<p><script src=\"https:\/\/gist.github.com\/philitell\/3979cdbba9e0b4c4b568212ab54d8005.js\"><\/script><\/p>\n<\/div>\n<div>Adapt your top-level flutter-widget to configure internationalization:<\/div>\n<div>\n<p><script src=\"https:\/\/gist.github.com\/philitell\/1c9f13460c08f7d9ae66d1b2f1983a4e.js\"><\/script><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<h3>5. Usage<\/h3>\n<div>First create a string inside your source-code as you would normally do it:<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f8144e6 elementor-widget elementor-widget-code-highlight\" data-id=\"f8144e6\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-dart line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-dart\">\n\t\t\t\t\t<xmp>return Text(\"GEMEINDE\");<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4b8d836 elementor-widget elementor-widget-text-editor\" data-id=\"4b8d836\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div>1. Position your cursor inside the string and press `ALT+ENTER`<\/div>\n<div>2. Select option`Extract to ARB File`<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1480447 elementor-widget elementor-widget-image\" data-id=\"1480447\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"531\" height=\"405\" src=\"https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/extract_arb.png\" class=\"attachment-large size-large wp-image-2948\" alt=\"\" srcset=\"https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/extract_arb.png 531w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/extract_arb-300x229.png 300w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/extract_arb-16x12.png 16w\" sizes=\"(max-width: 531px) 100vw, 531px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-57340e9 elementor-widget elementor-widget-text-editor\" data-id=\"57340e9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div><div>3. Select a name for the variable that should replace the string<\/div><\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-40e6776 elementor-widget elementor-widget-image\" data-id=\"40e6776\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"394\" height=\"392\" src=\"https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/Bildschirmfoto-von-2022-05-13-10-57-05.png\" class=\"attachment-large size-large wp-image-2947\" alt=\"\" srcset=\"https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/Bildschirmfoto-von-2022-05-13-10-57-05.png 394w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/Bildschirmfoto-von-2022-05-13-10-57-05-300x298.png 300w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/Bildschirmfoto-von-2022-05-13-10-57-05-150x150.png 150w, https:\/\/itell.solutions\/wp-content\/uploads\/2022\/05\/Bildschirmfoto-von-2022-05-13-10-57-05-12x12.png 12w\" sizes=\"(max-width: 394px) 100vw, 394px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-924c911 elementor-widget elementor-widget-text-editor\" data-id=\"924c911\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>4. The Plugin will then replace the string with a variable.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5100d0c elementor-widget elementor-widget-code-highlight\" data-id=\"5100d0c\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-dart line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-dart\">\n\t\t\t\t\t<xmp>return Text(S.of(context).categoryNotFound);<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-200a205 elementor-widget elementor-widget-text-editor\" data-id=\"200a205\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>5. The arb-File for each locale contains the variable for the given string. Here you can enter your translations.<\/p>\n<script src=\"https:\/\/gist.github.com\/philitell\/344e5eb98b07a654dcf5f0b90b2cdc6c.js\"><\/script>\n<p><strong><em>And that\u2019s it &#8211; you have successfully internationalized your Flutter application.<\/em><\/strong><\/p>\n<h2 id=\"want-more\">Want more?<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>For further information about our Software Development, find us on <a href=\"https:\/\/itell.solutions\/en\/\">itell.solutions<\/a>. For more information about this usefull plugin visit <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/13666-flutter-intl\" target=\"_blank\" rel=\"noopener\">flutter_intl for Android Studio<\/a><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Internationalization is an important part when we are developing modern Flutter apps. We show you how this can be done &#8211; easy and fast.<\/p>","protected":false},"author":11,"featured_media":2956,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,1],"tags":[48,45,46,50,47,44,49],"class_list":["post-2944","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wissen2go","category-allgemein","tag-android-studio","tag-app","tag-flutter","tag-flutter_intl","tag-internationalization","tag-intl","tag-localization"],"_links":{"self":[{"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/posts\/2944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/comments?post=2944"}],"version-history":[{"count":28,"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/posts\/2944\/revisions"}],"predecessor-version":[{"id":3114,"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/posts\/2944\/revisions\/3114"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/media\/2956"}],"wp:attachment":[{"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/media?parent=2944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/categories?post=2944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itell.solutions\/en\/wp-json\/wp\/v2\/tags?post=2944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}