Localize strings returned by a web service - android

What would be the best design to localize strings in Android that come from a web-service hosted on Google app engine?
My Android application calls a REST web-service that returns items. Each item has a "tags" attribute that contains strings.
Server-side, these tags are stored in the datastore, in English, in the item (with a StringListProperty).
The handler is hardly more complex than:
class MyHandler(webapp2.RequestHandler):
def get(self):
item = MyModel.get_by_id(id)
self.response.write(json.encode(item))
I wonder what design recommendations you can suggest to localize this "tags".
Localize server-side? This does not sound very usual (flickr, stackoverflow, etc.) don't do that. And, then, how to handle the localization? (see code snippet above)
Localize client-side? Then, what is the most efficient way to do that?

In www.cloud4apps.com you can find a free cloud web service that works similar to StackOverflow that enables the power of crowd-sourcing where users post and vote for best entries.
Then the services determine which string resources to use in your app based on votes and your approval or automatically if desired.
You can upload your current Android resource files into the online tool and Download latest translations as Android resource files or use the SDK to pull data in real-time.
Their SDK implements caching that allows your app to still use text resources even when offline.

Related

ASP.NET Registration Form to a Simple Offline-capabled Mobile Application

My question will be really long but I encourage you to read through everything as it will be used for an honest, good cause. Or you can skip to the highlighted questions part.
Let me introduce myself first, I am an independent web application developer here in the Philippines and I work for a non-profit organization where we help less fortunate people by providing IT solutions and services for free. I have a working web application that has dynamic registration forms where users can enter their data online. I developed this application with responsive UI using bootstrap's grid system. But being here in the Philippines, there are remote areas where the target clients don't have access to the internet 24/7, and bringing laptop or desktop computers is a pain because of the terrain and rivers that we need to cross to reach these remote areas.
Now, together with my team, we are thinking of a way to use our mobile phones, mostly androids to create a mobile app version of our web application. Where it can download the registration form (html) when we are connected and then use it even without internet connection.
Ideally the situation should be:
1. Launch the app from my mobile, and while connected to the internet, download the html forms needed from our web application.
2. Travel to remote areas, use the mobile application to encode the native's information offline. (I heard its possible to save it locally to sqlite db)
3. Go back to the headquarters and sync with the online web application to pass all the information gathered and thats it.
Having said all that, I have 3 questions:
1. What should I use to create a mobile app that can display html forms downloaded from the internet?
2. How can I save the data locally (within the phone)? I heard about sqlite db but I am not sure if it will work with my situation.
3. How can I sync the locally saved data to the online web application?
This is more like a survey application. You dont need the html here. You design your question definitions in xml or json. You may have multiple types of question like Text Answer Question, Single Choice Multiple Option Question, Multiple Choice Multiple Option question, Image Question, QR Code Question, GPS Coordinate Question etc etc. You design these questions in json or xml and put them in server. For example
{
questionSetName: "Question Set 1",
question:[{
questionText: "What is your name ?",
questionType: "TextAnswer"
},
{
questionText: "Which one console below do you own ?",
questionType: "SingleChoiceMultipleOption",
options:["PS4", "XBox", "Steam Console"]
}]
}
Now for your mobile client:
When online user will want to download questions for later offline surveys. so user send a request to server for available question sets. then will pull these file from server (in case of android through some HttpClient like OkHttpClient) and put them in sd card. The server will implement rest apis for question lists and downloading individual question sets.
The application will check if files are present in a certain folder (your app designated folder) in the sdcard. The file names will be the list of the questions.It will parse the json or xml and render question windows accordingly, for example for text question a label with the question text and a text box for answer, for single choice multiple options a set of option buttons, for image questions open the mobile camera etc.
When filling up (answering) the questions you save the answers and question number and flush them in a json file. and put the answer files in another directory (you need some sort of identification).
later on upload the answer files to server.
The server side will require the following rest apis :
1. List of Question Sets of a user (from db ??)
2. An api (webservice) to download a set of questions.
3. An api to upload an answer sheet for a question.
4. user management of course.
Hope this helps.

Reusing code between Android and Google App Engine

I'm new to GAE, but have worked on Android for a while now. I'd like to write some code that basically parses xml files and stores it on a database at the backend. Then send part of this data based on a query to the front-end android app.
The android app in turn will store the data in the local database. Here, if possible, I would like to reuse code from the GAE and the Android app. So, my questions are:
what are the choices for databases on GAE?
which methodology to use to promote code reuse with backend and frontend?
is there any xml parser which can also be reused?
Thanks,
Rajath
in GAE basically you have two non exclusive choiches: The Google Cloud SQL and the Datastore.
Which is better and which to use it depends on your application. The SQL server is a classical mySQL base database while the Datastore is based on a different non-relational structure and you should take some time to get familiar with it.
Generally speaking you can reuse code being in both cases Java, however there are many cases in which you interface with different services (ex. a local android sql service rather than the google datastore) therefore in this cases you have to adapt your classes. I can suggest in these cases to reuse concepts rather than code, let me explain: imagine you have to manage images. you take a picture in android and you have to associate to it some informations, for this purpose you can define a custom data model (let say a class AppImage). AppImage will contains only data and basic methods. Then you can for example create a class that manages AppImages (ImagesManager) (implementing upload, local storage and so on). In the serverside tyou will have a similar structure with that can differ for the persistency technologies. Therefore you can again create a similar object AppImage and also a class that manages them (ImagesManager). What will be different in the code will be the API calls to store info and in these cases you have no choiche and you have to write custom code, however the high level structure remains the same and this may help when things start getting complex.
The comment above worth also for the xml parsing problem. (What libraries are there for processing XML on Google App Engine/Java Servlet)

What's the proper way of importing option lists into an Android app?

I have been storing option lists for my Android app in a cloud table. For example, categories like "historical fiction","biography","science fiction", etc. I see the following pros and cons:
Pro:
I can make changes to the list without sending an app update to Google Play
Not normalized - I can use the text in my other data tables instead of a reference ID
Con:
App needs to take time to download from the web each time (or at least check for changes)
English only
I believe the "proper" way to do this is the use the XML resource files. But I need to make sure the selection references correctly with my data. That is, my app needs to understand that "Poetry" and "Poesía" are the same thing.
Is the correct thing to do:
Forget about it since I'll never get to the point where I'm translating my app anyway
Use a string-array and use the index (0...x) to know what the selection is
Use a 2-dimensional string-array with a reference ID in the first column and the text in the second?
If you are handling the category list online, then why not handle the translations online as well. Here is what I would suggest:
In your application options, have a list of supported languages (each in their native translation). These language options should be stored on whatever server application is handling your web requests. Each language is associated with an integer ID that the user does not see, but is stored in the app.
Whenever you issue a web request to get a list of options, include the language id in the message. This will allow you to know what language the user has picked and can use a 2D array or some other structure to handle the conversion to and from the chosen language.
I'm not sure if this helps at all, since I don't know exactly what you are making or how you are designing it, but from the given description, this is an easy and effective course of action.

iOS & bootstrap connecting to external database

I am doing some investigation into developing a iOS App, Android App as well as a bootstrap website. This is really at the early stages of the project and I have been out of software development for a number of years so I am a little rusty, so please forgive me for my questions.
To connect to an external database and/or external C# code from an App, I presume you need to use a webservice? Is this the only way to do this?
What format is required? JSON?
From a bootstrap website, how would I go about doing the same thing? Via a AJAX call to a webservice?
Do most Apps use the internal storage/database for storing data? (I know that's a very general question, I am just trying to get a feel for things)
Thanks for your help.
You will need a web service. Theoretically you can connect to the databases directly with android and iOS, but that's less secure, and making changes is difficult. For example, if you ever want to rename a column in your database, you would break your existing apps. However, if you use a webservice, you can update the webservice to report the column under it's old name.
You can use whatever format you want, but I would strongly recommend JSON. There are lots of powerful, fast parsers out there to handle serializing and deserializing JSON strings out there, and some networking clients that will even handle the translation automatically for you.
You would indeed use an AJAX call.
Yes, that is very general, but most apps will. It really varies what kind of data you need to persist. If you're just looking to cache a feed until the next launch you may use a simple file storage (in iOS you can use a NSKeyedArchiver to quickly build objects into a file format and NSKeyedUnarchiver to build objects from a file), or if you need more complex data relationships you would use a SQLite database on the device. On iOS you should use Core Data to manage the SQLite store for you.
You are correct. To get data from an external database you will need to make a webservice call To a script that returns the data you wish to use.
You can get the data back in JSON or XML format. I prefer JSON as I think it is easier and simpler.
AJAX would be a good way to make calls for your data.
Its a good idea to make a mix of both. You can use and webserver to store all your data but if the user is in an area that they can't use data then it would render your app useless. Normally I keep all the data I need on a server then download and store it in the apps DB for that user. You can then make a request to the server at intervals to see if there is any new data to be downloaded. I would suggest doing a similar thing for the bootstrap site.

How to detect New Version Of Website using Android Application?

I have an android application that's a "link" to a magazine website.
The activity of the application would be the magazine website itself.
I've made a widget for it and I run a service that as one sole purpose: to detect when a new magazine is online. When the service detects it changes the widget icon.
Now my doubt is how can I detect a new magazine. I was thinking about download a file from the website every 6 hours and compare the version of the last magazine (I may start with 0 as a local variable for the application and compare with the number provided by the document downloaded).
Is there a better way to do it?
It depends what you consider to be a "change". Assuming you want to detect any changes, download the magazine homepage/other file and perform an MD5 or similar hash on it. Store the hash.
Next time you do a download, you hash it again then compare hashes. If the hashes are identical, the page is unchanged. The benefit of the hash is the reduced storage requirements - you only need to save a handful of bytes, not a whole document.
Be aware, however, that most pages are NOT static - imagine a page with a clock in the corner or any dynamic content - in this scenario, your page will always appear to be different.
For some well-run sites and servers, you may be able to look at the HTTP headers to get information about when the page was created/modified/is set to expire. This won't be provided by everyone and can sometimes just be plain wrong.
The ideal solution is to find one particular page (or part of a page) which will onlu change once with every new issue - then you can just keep checking that one thing. An example of this might be a link that always points at the latest issue or the url for the main image which changes with each issue.
Of course, if the magazines are willing to help, they could expose the information to you in a number of ways from a simple file with just an issue number inside to a full-on webservice.
Edit: Assuming multiple magazines under your control, I'd suggest you have a single page that returns a list of the latest issues for each magazine in a readily parsable format (JSON, XML). This list could be static if issues are infrequent/a very manual process - in which case, edit it by hand. Even better would be a simple database table which is read to generate the list - This way you can have a nice UI to update it and allow someone else to maintain it without giving them access to the server file system.
I'd also suggest that you assign a truly unique id/key to each magazine and to each issue of that magazine - so that in future, you can add other functionality like downloading locally for offline reading / syncing back issues.

Categories

Resources