Is there a strings or language file I can add to an Ionic project? - ionic-framework

How can I make a language/string file and reference it in the HTML and code base?
It would help reduce spelling errors, make it easy to change in one place, and easier to translate.
Kind of like android studio's strings.xml.
Thanks.

It depends on the javascript framework that you're using behind the ionic-framework.
In case of angular , you can consider the ngx-translate , once you configure it , you can put your strings inside a json file , and you'll be using the keys to match the translations/full-text.

Related

Flutter: Localization from API call

I wish to localize a Flutter application where locales are fetched by an API call, given the requested language.
I was hoping to be able to use the Intl package or something similar, but I am not sure this is possible without the .arb files.
Any ideas on how to accomplish this without reinventing the wheel?
(Having the localizations stored locally is not an option)
Down below, you can see a class which is converted to a singleton pattern. You can use any service locator package. It will be the same thing.
Now you can call this class in your main function, default set to EN.
Now let's say, you want to support SPANISH and not want to use .arb files
Now you can call google translate and replace values with the existing one. for every variable. I hope this helps.
Use https://pub.dev/packages/localizely_sdk package, it provides what you want to achieve
Turns out easy_localization has the functionality described. Simply creating a custom HttpAssetLoader and passing it to the easy_localization initialization method works out of the box, and provides device language detection, and application rebuild on locale change as intended.

Call a Dart const from a String version of its name

I am using Flutter and the FontAwesome library and I need to create icons based on their name. So, I need to get the following:
FaIcon(FontAwesomeIcons.lightWalking);
...but from its name as a String.
Something like this:
FaIcon(FontAwesomeIcons["lightWalking"]); // <== this doesn't work in Dart
I can then build a function to return icons based on the name that I get out of a database.
I don't think this is a dart related question on first sight but rather a FontAwesomeIcons question unless you want to use reflection in dart. You need to access the Icons here which are simply not accessible the way you tried it.
See the following issue:
https://github.com/fluttercommunity/font_awesome_flutter/issues/102
Quote:
Hi, we don't support icon maps officially, but you can use this
generator by calling it in the updater tool. You will need a local
installation of font awesome for this, please follow the instructions
for pro icons and ignore steps that mention icons.json or .ttf files.
If you need further assistance feel free to ask.
That means the way you are trying to access your icons is not supported directly.
However you could use the generator tools to create such a map, iterate it and find a suitable icon. See the FontAwesome example for that (they generated a map and iterated it).
https://github.com/fluttercommunity/font_awesome_flutter/tree/master/example/lib
What might be a little more convenient might be a third party tool which already has such a map and allows you to search it.
https://pub.dev/packages/icons_helper/example
You can then do the following:
getIconUsingPrefix(name: "PREFIX.ICON_NAME")
You can achieve this only using reflection. There is a library called reflectable for Flutter. It will generate some code for you and then you will be able to access the class members of FontAwesomeIcons by their name as String.

Native URL Endpoints .plist for Ionic2/Swift stack

I work on a Ionic2/Cordova project and I am developing custom native plugins for accessing rest API's. As native, the language is Swift which is transpiled with Objc decorators to be able to match with Cordova.
For accessing this API's I need some strings with url endpoints. This is mocked right now by using a key value dict but I want to move everything into something accessible by every native plugin. One suggestion was to create a .plist file (URLList.plist) with the content of this dictionary
From what I understood, on a native project this would be in the resources and it would be called like this: Bundle.main.path(forResource: "URLList", ofType: "plist").
I don't know where should I add this plist in the Ionic project so that it will compile well so I can reference it in the Native code. I tried almost everywhere in the structure but I can't figure it out.
Thanks in advance!
I solved the issue by using cordova-custom-config
Adding then to the config.xml the required dictionary, on ionic build platform it will build and populate the plist.
After this, I used Swift to get the dictionary values.
I mainly solved the problem, though, I wanted to use a separate plist, not the main project plist.

How to debug with createJS's objects

I am using createJS for a game, but when I debug the code with console, I got all objects displayed as an a. Then I have no idea what the object really is.
What does the a here mean? And what's the best way to debug these code?
This is due to the minified source. Instead, use the combined source. You can get a combined version of each library in GitHub, which is one file containing all the classes, but just appended, instead of minified.
If you are using the full combined suite on the CDN, then you can change the path to .combined instead of .min: https://code.createjs.com/createjs-2014.12.12.combined.js
Cheers.

Add language pack for anysoftkeboard

I'm now trying to add a new language for Anysoftkeyboard.
But I don't quite sure how create a language wordlist and make it a language package for Anysoftkeyboard.
I'm now creating a Binary Dictionaries as this URL but don't know what the next step is.
Could anyone be so kind to tell me the steps of add a new language to AnysoftKeyboard?
Besides I download the database from here and what I trying to add is Chinese and Vietnamese.
Other method for making a Android softkeyboard is also appreciated.
You can create an android app language pack for AnySoftKeyboard https://github.com/azzamsa/LanguagePack
You need to put the new binary dictionary in the assets/path, and add a similar entry into res/xml/dictionaries.xml: dictionaryAssertName="dict.mp3".
You may find a full example of a language pack here :
https://github.com/ludovig/vimboard/tree/master/android-vimboard-ask
I'm using AIDE to clone package and build it on my android device.