I have Android Application which are supprting multilanguage (Russian & Latvian), no questions to this.
Problem is, that my backend is on CI and I have some definied Strings (mostly technical), example (Russian):
define('ALL_CAT',"Все категории");
define('NO_DATA',"Ничего нет.");
And if Application is in Latvian, then I will in any case see this Russian strings.
Is it possible somehow translate Backend CI Api Strings?
(Or, move all API string to client and show them from client - if this possible, idk)
PS: Also I have no saved Language on client side. It means if User open Application and select Latvian, use Application on Latvian, but when application closed/reopened user must select Latvian again ;-)
Thank you in advance,
Yes. The solution is to send a placeholder instead of russian.
define('ALL_CAT',"placeholder::ALL_CAT");
define('NO_DATA',"placeholder::NO_DATA");
Then, whenever your client encounters a placeholder string:
String recieved = getStringFromServer();
if(recieved.indexOf("placeholder") == 0){
recieved == //rusian or latvian.
}
You translate that placeholder string with a lookup table. You can define that lookup table in a file in your app, or in a database on a server somewhere.
Related
I'm trying to give the user the option to save their passwords after registering on a website, using the autofill service provided by android.
List<FillContext> contexts = request.getFillContexts();
AssistStructure structure = contexts.get(contexts.size() - 1).getStructure();
ParsedStructure parsedStructure = ParsedStructure.parse(structure);
parsedStructure.getPasswordView().getText().toString()
This code is in the onSaveRequest method of Android's AutofillService.
When I log the last line, the text in the console only contains asterix characters and not the password itself. Does anyone have an idea why that is and an solution for that?
AS most of the browsers are in Compatibility mode and do not support the native autofill api yet.
Read more at the android documentation.
A few years ago I created a bot with telegrambots version 3.6.1.
Unfortunately there was a problem: every time that a user with user_ID>2147483647 joined the group, the bot crashed, as described here.
I've just found out how to update the version of telegrambots, but now I've another problem.
I need to use the setPhoto(String file_id) method as described here in Telegram ot JAVA API page (Pass a file_id as String to send a photo that exists on the Telegram servers).
It looks like that method doesn't accept String parameter anymore since telegrambots version 5.0.0.
Infact it worked until telegrambots version 4.9.2.
So my bot pins a message in the group with a list of many places, each one can have up till 2 photos.
Each of these photos has its file_id saved in a field of a MySql database.
So basically when we use the command to see a pic associated to a place, my code uses setPhoto(file_id) getting the file_id string from the database.
Now it looks like setPhoto(String) doesn't work anymore, so how can I solve this problem? I still need to use all the photo we saved in those years. How can i convert these file_id into InputFile argument?
I've tried to use version 4.9.2 of telegrambots and setPhoto(String) works, but I don't know if in that version, my original problem (numeric value out of range) was already solved and anyway I would like to use the latest version (6.4.0).
I've no idea how to convert String (fileID from database) to InputFile.
Thanks you very much.
The documentation is not really documenting anything, but it looks like the FileInput constructor can take String called attach(ement).
I am trying to get the forest Data directory in MarkLogic. I used the following method to get data directory...using the Server Evaluation Call Interface running queries as admin. If not, please let me know how I can get forest data directory
ServerEvaluationCall forestDataDirCall = client.newServerEval()
.xquery("admin:forest-get-data-directory(admin:get-configuration(), admin:forest-get-id(admin:get-configuration(), \"" + forestName +"\"))");
for (EvalResult forestDataDirResult : forestDataDirCall.eval()) {
String forestDataDir = null;
forestDataDir = forestDataDirResult.getString();
System.out.println("forestDataDir is " + forestDataDir);
}
I see no reason for needing to hit the server evaluation endpoint to ask this question to the server. MarkLogic comes with a robust REST based management API including getters for almost all items of interest.
Knowing that, you can use what is documented here:
http://yourserver:8002/manage/v2/forests
Results can be in JSON, XML or HTML
It is the getter for forest configurations. Which forests you care about can be found by iterating over all forests or by reaching through the database config and then to the forests. It all depends on what you already know from the outside.
References:
Management API
Scripting Administrative Tasks
I am new to Android and Windows Azure. I have successfully inserted data from Android application but how do I retrieve single data and post that data on a TextView?
The read function after the gettable class is also not working. What is the exact function use for it? I have followed these instructions but they did not work for me, also I do not understand the documentation.
Currently, I just can provide some tutorials about how to use query data from azure database. I recommend you can refer to this official document about how to use Azure Client Library using Java: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-how-to-use-client-library . You can focus on two part: “how to query data from a mobile service” and “how to bind data to the UI”.
At the same time, you can view this video from Channel 9: https://channel9.msdn.com/Series/Windows-Azure-Mobile-Services/Android-Getting-Started-With-Data-Connecting-your-app-to-Windows-Azure-Mobile-Services.
The sample code project of this tutorial, please go to the GitHub link https://github.com/Azure/mobile-services-samples/tree/master/GettingStartedWithData .
For the ‘getTable(Class )’ function is not working, please double check whether the class name is same as table name. If they are same, you can use it like below:
MobileServiceTable<ToDoItem> mToDoTable = mClient.getTable(ToDoItem.class);
If not, you can write you code like this:
MobileServiceTable<ToDoItem> mToDoTable = mClient.getTable("ToDoItemBackup", ToDoItem.class);
For further better support, please share more detail about your code snippet .
I have a template accountlist.scala.html looking like this:
#(accounts: models.domain.AccountList)
#titlebar = {<p>some html</p>}
#content = {
#for(account <- accounts) {
<p>#account.name</p>
}
}
#main(titlebar)(content)
... and another template account.scala.html like this:
#(account: models.domain.Account)
#titlebar = {<p>#account.name</p>}
#content = {
#for(transaction <- account.getTransactions()) {
<p>#transaction.detail</p>
}
}
#main(titlebar)(content)
From both of them I am invoking the template main.scala.html.
I have access to the entire Account POJO in the first view accountlist.scala.html, so really there is no need for me to invoke the server to get the details of the account when I go to the view in which I display the details. I would just like to change view on the client side. How could I call the second view account.scala.html from the view accountlist.scala.html a user clicks on an account in the list? I am ready to change the templates as needed.
I have provided a previous answer, which is still available at the end of this post. From your comments, however I understand that you are asking for something else without understanding how dangerous it is.
There are three ways of handling your use case, let's start with the worst one.
A stateful web application
If you have loaded data into a Pojo from some data source and you want to re-use the Pojo between multiple requests, what you are trying to do is to implement some kind of client-state on the server, such as a cache. Web applications have been developed in this way for long time and this was the source of major bugs and errors. What happens if the underlying account data in the database is updated between one http request and the following? Your client won't see it, because it use cached data. Additionally, what happens when the user performs a back in his browser? How do you get notified on the server side so you keep track of where the user is in his navigation flow? For these and others reasons, Play! is designed to be stateless. If you are really into web applications, you probably need to read about what is the REST architectural style.
A stateless web application
In a stateless web applications, you are not allowed to keep data between two http requests, so you have two ways to handle it:
Generate the user interface in a single shot
This is the approach which you can use when your account data is reduced. You embed all the necessary data from each account into your page and you generate the view, which you keep hidden and you show only when the user clicks. Please note that you can generate the HTML on the server side and with Javascript makes only certain part of your DOM visible, or just transfer a JSON representation of your accounts and use some kind of templating library to build the necessary UI directly on the client
Generate the user interface when required
This approach becomes necessary when the account data structure contains too many informations, and you don't want to transfer all this information for all the accounts on the client at first. For example, if you know the user is going to be interested in seeing the details only of very few accounts, you want to require the details only when the user asks for it.
For example, in your list of accounts you will have a button associated with each account, called details and you will use the account id to send a new request to the server.
#(accounts: models.domain.AccountList)
#titlebar = {<p>some html</p>}
#content = {
#for(account <- accounts) {
<p>#account.name <button class="details" href="#routes.Controllers.account(account.id)">details</button></p>
}
}
Please note that you can also generate the user interface on the client side, but you will still need to retrieve it from the server the data structures when the user clicks on the button. This will ensure that the user retrieves the last available state of the account.
Old answer
If your goal is to reuse your views, Play views are nothing else then Scala classes, so you can import them:
#import packagename._
and then you use it in another template:
#for(account <- accounts) {
#account(account)
}
The question reveals a misunderstanding of play framework templates. When compiling the play project the template code is transformed to html, css and javascript.
You can not "invoke"/link another template showing the account transactions from a href attribute of your Account row. However, you can do any of the following:
In case you have loaded all transactions from all accounts to the client in one go: extend the template to generate separate <div> sections for each account showing the transactions. Also generate javascript to 1) hide the overview div and 2) show the specific transaction div when clicking on one of the accounts in the overview. Please see the knockout library proposed by Edmondo1984 or the accordion or tabs in twitter bootstrap.
In case you only load the account overview from the server. Generate a link such as this one href="#routes.Controllers.account(account.id)" (see Edmondo1984 answer) and make another template to view this data.
Since the question concerned a case in which you got all data from the server, go by option 1.