Edit translation text at runtime from server - android

Overview
AFAIK on Android you have twi ways to set the texts of your application:
You can use string.xml with different locales
You can download strings from server and set every label with a setText(language.text) but it will be a pain
The problem might sussist if you have to change a text of your published application without re-publishing it; for example if you want to change for a specific translation a small text without any functionality change. (ie: you might notice that you wrote "Take picure" instead of "Take picture").
Library
i18next is a good library to manage translations dinamically from server, but you still have to add the text for each label you got.
So, my question is
Still AFAIK, there is no way to do it natively, but is there a low level library or a workaround that allows to replace a string in your string.xml with some downloaded text?
Another option could be to make our label text to point instead of at #string/myValue to something like #myresource.pathtovalue.
Honestly I think this could be an huge improvement for application, is there something useful?

Related

Convert text into typographic styles (i.e text swag) programmatically

I want to build a functionality where a submitted text/quote is output into different beautiful text designs/layouts based on predefined templates. These templates convert the user-inputted text using a combination of different fonts, varied font styles, varied sizes and in a particulat format.
There are varieties of app present on playstore or appstore which do this.
examples:
Wordswag, Typimage & Typostyle for android and
Typorama for iphone
Can anyone help me with the logic behind this wizardry or point me towards any libraries on GitHub having similar features.
e.g.
Take the phrase "Stop hating yourself for everything you aren't and Start loving yourself for everything you already are".
Check below GIF which shows how on clicking various pattern options, the software converts the above plain text dynamically into beautiful designer text.

Multiple Language Support Android APP

I am very new for developing the multi-language oriented Android APP. This is the first time i am going to support my app in multi-support language app. I need some clarification for developing the multi-language support app. Already i have some ideas before initiate the development.
Single APK with Localization like will make the multiple String.xml and include it in inside of the app and based the member selection of language its automatically invokes and works.
All language strings values will retain in app server (back-end) and will raise the Rest-API request and get those values and change it inside of the entire app (all screens) if member click and change the language inside of the app.
Main concern is if anything needs to change in future then Idea2 is best way. We will just change in back-end side it will be appeared in client side. But if we are going Idea1 and wants to change then we need to put the new build only.
Which one is best approach and recommended way to develop?
You will need to create different String.xml depending the languages you want to target as JDenais says, in my app i have the following
for example the first arab string consist in the same as Strings.xml but with all in arab, now, you only need to call one string in your xml files and it will just select where to grab depending on the phone language. Or in default the language from where the app was downloaded by google play, in fact, they are all the same strings.xml , so you dont need to specify which one you want to pull the translated text from, just replicate your main strings.xml in your other strings.xml and then the phone will decide where to pull the data.
Also please read the official doc on how to accomplish this https://developer.android.com/training/basics/supporting-devices/languages
Also please check the language ISO Codes here
What is the list of supported languages/locales on Android?
All your texts should be packaged in the APK in different String.xml files. Forget about receiving texts from a backend. It would be a lot of extra work for limited gain and with added risks of failure.
The framework takes care of selecting the appropriate string.xml file and offers support for needed use cases like plurals.
right click the values folder and choose new-> values resource file -> locale -> choose the language you want and name it strings.
copy the strings from the original string file to the new file and change them to the new language just the strings
make sure that the view xml files have their text set as "#string/the_name of the string" not hard coded

How to limit the use of certain character sets

I hope this question isnt going to be down-flagged for not showing some actual code, but thats the core of this situation. I simply have no clue where to start to solve this issue, even after trying to use several combinations of keywords on both Google, and here on SO.
My client suddenly decided that half of the Android App I'm developing for him has to be Chinese, so after I have made some changes in the Database so some fields can take in Simplified Chinese character sets, I need to make sure that my client (living in holland) only uses those characters in that particular EditText field in the app. (There are more Database fields that now only allow Simplified Chinese, however these values come from a dropdown list in the app, so I dont need to worry about wrong characters for them).
So how would one make sure that only Simplified Chinese is used in an EditText field?
Here is a project in Ruby that attempts to detect whether characters are Traditional Chinese, Simplified Chinese, or Japanese (maybe others?): https://github.com/jpatokal/script_detector
This detection is based on the Unihan Database, in which there is a file called Unihan_Variants.txt. (Download zip file containing this text file here.)
Conceivably, you could parse the txt file into a lookup table and check the unicode value as the text is entered during onTextChanged() for your EditText. However, the readme on the project linked above states: "It is important to understand that this requires long sections of text to work reliably, since a single character or even several characters may be valid Japanese, traditional Chinese and simplified Chinese simultaneously." So, weeding out characters on an individual basis might prove difficult.

Change set of strings based on app purpose

I'm building an Android app that can be used for two different purposes, say biking and running. I would like to load the sport-specific keywords given a user's preference. They could be defined in different files, like strings_biking.xml and strings_running.xml .
How can I implement this as efficient/elegant as possible? I've taken a look at locales, styles, themes and lots of other topics in the Android documentation, but nothing seems to fit well enough.
AFAIK it does not support such distinguish as per category. strings.xml are used for localization only. For your purpose, you can define some prefix/suffix to the string name. While using them in activity, create string runtime by applying that prefix/suffix and string name for biking or running or any other condition.
May be this link can help for dynamic creation of string.

ANDROID: What is the main idea behind of using strings.xml?

Someone please explain what is the main idea of using strings.xml?
I think it would be useful for multi-language support but how can we organise it for that?
Do I need it if I don't want to use multi-language support in my android application?
The idea is that it represents a single location for various strings, so your code isn't peppered with string literals. In addition to that, you gain the ability to easily localize. Organization of files for localization is covered here:
http://developer.android.com/guide/topics/resources/localization.html#creating-alternatives
Do you need it if you're not localizing? No. But it may make things easier in the long run, and I would recommend using it just for that reason.
Hard-coding strings is Bad.
Parameterizing strings (e.g. with strings.xml) is Good.
Being able to internationalize your strings (with language and/or locale-specific versions of strings.xml) is even Better :)
PS:
To make use of internationalization, just create resource subdirectories. Google will give you plenty of references/examples. Herre's one:
http://developer.android.com/guide/topics/resources/localization.html
* res/values/strings.xml
Contains English text for all the strings that the application
uses, including text for a string named title.
* res/values-fr/strings.xml
Contain French text for all the strings, including title.
* res/values-ja/strings.xml
Contain Japanese text for all the strings...
And yes, you should absolutely get in the habit of using strings.xml (and colors.xml and dimens.xml etc etc) even if you don't plan on internationalizing immediately.
IMHO....

Categories

Resources