Convert ISO2 country code - grails

My goal is to concert a code like 'CH' in Switzerland , I want to convert it in the language of the locale of the users browser
I tried to use the country tag provided by grails:
<g:country code="che"/>
But it seems working only with IOS3 codes.
Anyone can help me?
Thanks in advice.

You can use the java.util.Locale instance yourself
def l = new Locale('de', 'CH')
l.displayCountry // will display `Switzerland` on a computer with English locale
l.getDisplayCountry(l) // will display `Schweiz`
l.getDisplayCountry(request.locale) // the answer to your question

Related

How to find multiple element in appium having same id in Python?

I am writing test code in Appium of an Andriod Project in python . The problem is that I am not able to access two button in two different Activity having same Id . I have tried to access the second button in this way.But none of them works. How to resolve the issue?
driver.find_element_by_id("com.myapp.testApp:id/login[1]").click(), driver.find_element_by_class_name("android.widget.Button").click()
driver.find_element_by_xpath("(//button[#id='login'])[1]").click()
driver.find_element_by_xpath("//android.widget.Button[#text='Change Password']").click()
Use .find_elements*:
elements = driver.find_elements_by_xpath("xpath")
#check elements number
print(len(elements))
#click second element
elements[1].click()
Can you try with textview:
driver.find_element_by_xpath("//android.widget.TextView[#text='Change Password']").click()
If buttons texts are different, try by accessibility_id
driver.find_element_by_accessibility_id("Login").click()
driver.find_element_by_accessibility_id("Change Password").click()
OR
If you are familiar with uiautomator,
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.myapp.testApp:id/login[1]")')
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.myapp.testApp:id/login[2]")')
You can use the get method with findElements:
driver.findElements(By.xpath("yourXpath]")).get(0).click();
You can do link this, It will give you proper Output:
Input is:
d1 = driver.find_elements_by_id("com.application.zomato:id/price")
itemtotalprice = d1[0].get_attribute("text")
Here, is my output:
Mandarin Oak
₹200
₹166.75

Get current input language on android (Xamarin)

Is there any way to get current input language?
I've tried this:
editText_input.TextLocale
but it returns default system language. Also I tried to look into
Android.Views.InputMethods.InputMethodManager
but no luck as well. Any suggestions?
It seems you could only get the keyboard language by using:
InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
InputMethodSubtype ims = imm.CurrentInputMethodSubtype;
string localeString = ims.Locale;
For example:

URLConnection with arabic parameters

i'm trying to develop an android application which contains arabic data , so i've got a problem ;
URL twitter = new URL("http://10.0.2.2/WS/identi_el.php?id1="+nomm+"&id2="+pren+"&id3="+pa);
these parameters (nomm , pren and pa ) are in arabic language so it doesn't return any result , however , when i put them in french it returns results so can anyone helps me how to make URLConnection supports arabic letters please ?
Non alphanumeric characters except -, _ and . are know to cause issues in URLs, I bet you'll run into the same problem if you use a french word with an accent.
So stay on the safe side and encode all parameters before using them as part query string parameters.
I modified the URL from
URL twitter = new URL("http://10.0.2.2/WS/identi_el.php?id1="+nomm+"&id2="+pren+"&id3="+pa);
to
url = new URL("http://10.0.2.2/WS/identi_el.phpid1="+java.net.URLEncoder.encode(nomm,"utf8")+"&id2="+java.net.URLEncoder.encode(pren,"utf8")+"&id3="+java.net.URLEncoder.encode(pa,"utf-8"));
=> I just added the following java.net.URLEncoder.encode(...,"utf8") for each parameter and it's working :)

Ruby - ERROR_Can't convert nil into an exact number

I try to make that, in the controller ...
raw_counter_reset_date = REDIS.hget(params[:id], 'overquota_reset_at')
#counter_reset_date = Time.at(raw_counter_reset_date)
But when I want lauch application, I have this error :
can't convert nil into an exact number
I know that #counter_reset_date = Time.at(1364046539) works with numbers, but I would that the application take the timestamp date in a database and convert in date on my web-page.
I hope to have been understandable, and thank you in advance for your help.
this is because raw_counter_reset_date is nil. convert it to a number (raw_counter_reset_date.to_i) or check for nil.

Call javascript in sharepoint custom field

I am creating a custom field in SharePoint 2007. I have seen other solutions where the current site URL was default value of a text field.
How can I get this current site URL?
I have got one answer whiches states that I shall use JavaScript, but where do I put the script?
I hope you can help.
BR
To answer 1
I am new to SharePoint and am not quiet sure where to put the java script. Normaly i just give the initial value to the field in the FieldEditor.cs file but how can I do this with the javascript?
Here follows a picute of my files.
I have tried to put it into FiledEditor.cs but this results in the value of myString is written in the top of the web page.
Here is my current code:
string myScript = "var currentUrl = document.URL; LabelLookupFieldTargetURLText.Text = currentUrl;";
Page.ClientScript.RegisterClientScriptBlock(LabelLookupFieldTargetURLText.GetType(), "LabelLookupFieldTargetURLTextJavaScript", myScript);
I found the answer my self. I don't need to use a java script. I can just use SPContext.Current.Site.Url
use javascript:
var nowUrl = document.URL;
yourTextfiled.value = nowUrl;
you can read this:http://www.w3schools.com/jsref/dom_obj_document.asp

Resources