Handling order of names in languages like Chinese - ios

In numerous places in my app, I have a name displayed (current user or other user). I have 3 fields for name: firstName, lastName and fullName. Full is simply firstName + lastName, and not used very often. I use 'firstName lastName' more often than fullName.
I recently localized the app into other languages, among them Chinese and Japanese, in which the order for names is reversed to 'lastName firstName'.
I am unsure how to handle this change now in my app. Has anyone encountered a similar challenge and how did you handle it?
Thank you

I figured out how to do this by saving a string called fullName in my Localizable Strings file as follows:
"fullName" = "%1$# %2$#";
Then, in the languages that have the name order different, their "fullName" string is like this:
"fullName" = "%2$# %1$#";
Hope this is helpful to someone else! :)

Related

Looking to fill out most or all of the Fed Ex "Create Label" page using URL query string

Looking to create a shipment on www.fedex.com
But fill out most of the fields using a query string at the end of a URL.
Seems like this might not be possible, but need help figuring out how to know whether it is or not.
My "Create Labels" page has a URL ending in -- ?method=doInitialize&utype=null ,
or else sometimes ...
-- ?method=doEntry&link=1&locale=en_US&urlparams=us&sType=F
so it seems promising. Just not sure how to access the names of the required fields (Contact name, Address 1 and 2, etc ) besides guess and check.
Thanks!
--------- Destination Section Parameters Found
The query string parameters for the destination contact field are, at the time this answer was written :
toData.addressData.contactName
toData.addressData.addressLine1
toData.addressData.addressLine2
toData.addressData.zipPostalCode
toData.addressData.city
toData.addressData.stateProvinceCode
toData.addressData.phoneNumber
psdData.mpsRowDataList[0].weight
Of course, they need to be appended to the original URL using valid query string syntax and URL encoding.
--------- How Were These Found ?
These were each found using the page inspector. I found that it is important to cut through the noise by zeroing in on the exact field where the data needs to be entered, and opening up the page inspector to that location.
Right click (Win) or control click (Mac) > "inspect"
This will bring up the following text in the inspector. By trial and error, I discovered that the "name" fields correspond to the working query string parameters.
The part we are looking for :
This corresponds to the query string parameter ...
toData.addressData.addressLine1
... originally listed above.
--------- Unsolved Parameters
It's a mystery why this same rule doesn't apply in the same way to other values in the page, like service type (e.g. "Priority Overnight") or package type (e.g. "FedEx Box"). The following, for example, do not fill as expected, even when using the exact same "name" field from the page inspector.
psdData.mpsRowDataList[0].carriageValue
psdData.serviceType
psdData.packageType
billingData.referenceData.yourReference
Maybe it's a URL encoding issue? Anyway, hope this helps.

Extract the content of text to be used in a Zapier action

Can someone please help with a code that will extract a name from a text. I am trying to create an action in a Zapier that will extract the Firstname and Lastname from a gmail. I've tried to modify the "Simple Email Extraction" example given here https://zapier.com/help/code/#introductory-examples , but need someone to point me in the right direction. The example gmail will look like this:
Navn: Firstname Lastname
Adresse: Streetadress
PostNr/Sted: Postalcode City
E-post: emailadress
Mobil: mobilephone
What I need to extract is the content of "Firstname Lastname" into an output that can be used in the action.
the Zapier email parser suggested by Matt solved this problem.

Add attributes to a NSLocalizedString with parameters

I have an NSLocalizedString which says something like this:
The house of David received 2 new offers.
Where the actual string is
NSLocalizedString(#"The house of %# received %i new offers", nil);
And I would like to add attributes on this string so it would look like this:
The house of David received 2 new offers.
It's amazing this is so hard. I tried to search for the parameters in the string, get their location and add the attributes, but it screws up when I want to change the string to "The 2 houses of david received 2 new offers". There it will make all the "2" strings bold.
Is there a better way to do this? After searching for days online I hope you guys can help me.

ransack searching each word in a text_field

I will searching with ransack in my Rails application for users by firstname and lastname. In one text_field for firstname and one text_field for lastname the application user should have the possibility to search for several parts of the name.
E.g. the user will enter "Thomas Jeffrey" and this should results in:
SELECT FROM users WHERE firstname LIKE "%Thomas%" AND firstname LIKE "%Jeffrey%";
If I use firstname_cont the result looks like:
SELECT FROM users WHERE firstname LIKE "%Thomas Jeffrey%";
When I was trying firstname_cont_all out, I got something different.
Thank you for any hint.
User.search(firstname_cont_all: params[:my_field].split)
I do not know, however, how to properly introduce that splitting to array when using ransack's condition_field form builder utility.

g:countrySelect with full country name as value

I want to store the exact country name using g:countrySelect. Example Germany instead of DEU. It is the value in the drop down menu. The drop down text is Germany but when it saves it to the database it changes back to the country code. Sorry if I am somewhat naive but I have been searching for almost 3 hours for solutions and it isn't well documented at the grails website. I could opt for any alternative even ajax. Just to have an easy way to display a list of countries and will be able to store the REAL NAME of the country NOT country code. Thank you!
You can convert from an ISO3 country code to the country name using this function
def getCountryName(String countryCode) {
Locale.availableLocales.find{it.ISO3Country == countryCode}.displayCountry
}
// Test
println getCountryName('DEU') // prints 'Germany'
If you want to do this within a GSP, it would be best to make this available as a TagLib.
Not sure when the above solution stopped working but if you try that now, you'll get an error:
Couldn't find 3-letter country code for CS
With the latest grail version, the current way of getting the full country name is by using this tag:
<g:country code="${country}"/>
I know this thread is old, but I was looking for the same issue and I had to share my solution.
You can use the CountryTagLib object to convert the ISO3 code back to full country name like this :
def country = CountryTagLib.ISO3166_3[code]
The "code" property being the ISO3 code that you got from <g:countrySelect>.

Resources