CSV to Plist Conversion IOS - ios

I need help turning my large spreadsheet into a plist. I want the key names to be Letters of the alphabet and the names to be values:
<plist version="1.0">
<dict>
<key>A</key>
<array>
<string>Amstel Light</string>
<string>Anchor Porter</string>
<string>Anchor Steam Beer</string>
<string>Anheuser Busch Natural Light</string>
<string>Asahi Draft Beer</string>
</array>
<key>B</key>
<array>
<string>Ballentine India Pale Ale</string>
<string>Ballentine Premium Lager</string>
<string>Ballentine Private Stock Malt Liquor</string>
<string>Ballentine XXX Ale </string>
<string>Bass Bale Ale</string>
<string>Beamish Irish Cream Stout</string>
<string>Beamish Red Ale</string>
<string>Beck Beer</string>
<string>Big Barrell Australian Lager</string>
<string>Black Horse Premium Draft Beer</string>
<string>Blatz Beer</string>
<string>Blatz Milwaukee 1851 Beer</string>
<string>Boulder Porter</string>
<string>Bud Light Beer</string>
<string>Budweiser King of Beers</string>
<string>Busch Beer</string>
I unfortunately had to enter these manually before, but my dataset is now enormous and contains about 1000 values. How can I automatically do this. I tried writing a Concatonate function in excel which gave me keys in the proper syntax but i still cannot copy and paste them easily due to formatting issues, basically It turns whole value into one line vs having it in four with the key, then array… The herokuapp method also does not create the keys in the way I need. Any help would be greatly appreciated.

Related

Localizable.stringsdict: getting English to use the "two" key [duplicate]

I'm trying to use the .stringsdict functionality in iOS programming to display the proper ordinal suffix (st, nd, rd, etc...) for numbers. I've created the .stringsdict file for english, but it's only using the 'one' and 'other' keys. It's ignoring the 'two' and 'few' options. Anybody see what i've done wrong here?
The file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>TEAM_RANK_ORDINAL</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%##ordinal_string#</string>
<key>ordinal_string</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lu</string>
<key>one</key>
<string>%lust</string>
<key>two</key>
<string>%lund</string>
<key>few</key>
<string>%lurd</string>
<key>other</key>
<string>%luth</string>
</dict>
</dict>
</dict>
</plist>
I then access it like so, from Swift. For the value 1 it appends st, but every other number appends th:
let fmt = NSLocalizedString("TEAM_RANK_ORDINAL", comment: "")
for i in 0...30 {
println(String(format: fmt, i))
}
The english locale ignores the "two" and "few" rules and uses
only "one" and "other".
See Plural Rule Properties in the "Internationalization and Localization Guide":
The meaning of the categories is language-dependent, and not all
languages have the same categories.
For example, English only uses the one, and other categories to
represent plural forms. Arabic has different plural forms for the
zero, one, two, few, many, and other categories. ...
There is (as far as I know) no way to use a .stringsdict file
for producing ordinal numbers.
While Martin answered your stringsdict question, for users who stumble across the "ordinal" issue, one should just use NumberFormatter for localized ordinal numbers. E.g.
let formatter = NumberFormatter()
formatter.numberStyle = .ordinal
for i in 1..<30 {
print(formatter.string(for: i) ?? i)
}
Producing (for English users):
1st
2nd
3rd
4th
5th
6th
7th
8th
9th
10th
11th
12th
13th
14th
15th
16th
17th
18th
19th
20th
21st
22nd
23rd
24th
25th
26th
27th
28th
29th
And, FWIW, even if the stringsdict approach worked for two, etc., doesn't have a prayer of differentiating between large numbers that use a different ordinality syntax, e.g. between 122nd and 124th. You really need to use NumberFormatter for this.

Using ".stringsdict" file with 'localizedStringWithFormat' --> Are NUMERALS localized for you?

I am trying to produce the following localized string:
"In ___ day(s)" --> (ex: In 5 days)
To accomplish this, I've gone down the .stringsdict route:
<key>In %d Days</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%##Days#</string>
<key>Days</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>Today</string>
<key>one</key>
<string>In %d Day</string>
<key>other</key>
<string>In %d Days</string>
</dict>
</dict>
I then use the following, to obtain a localized string:
NSInteger days = ...;
localizedDueDateString = [NSString localizedStringWithFormat:NSLocalizedString(#"In %d Days", #"Indicates days"),ABS(days)];
This correctly outputs a string that accounts for plurality. For example:
In 1 day
In 4 days
I am wondering if the "1" and the "4" here will be localized correct. Other languages, like Arabic for example, have different symbols for their numerals. I would expect the above string to use the symbol "٤" instead of "4", for arabic.
I know this can be accomplished using an NSNumberFormatter, but how can I accomplish numeral localization while ALSO respecting plurality visa vi a .stringsdict file?
YES
Numerals do appear to be correctly swapped when using a .stringsdict file in coordination with "localizedStringWithFormat" method!
I switched my iPad language to Arabic, and the output for
In 1 day
was...
١ day In
I don't have an arabic localization done yet, so "In" and "day" are english, but the numeral appears to be correctly localized. No need for NSNumberFormatter

iOS9 GoogleAnalytics and NSAppTransportSecurity

I am running into trouble due to the new security opportunity from Apple's iOS9 to restrict ssl requests to any kind of servers.
See reference: https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33
Actually, I want to make use of the default and not allow any kind of connection
NSAllowsArbitraryLoads: false
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
</dict>
Of course some connections are intended and I retrieve data from own servers as well as from third party servers.
Either you can now sniff the app's traffic, which is generated by third party tools, or you make use of logging all network traffic, referenced here:
How can I figure out which URL is being blocked by App Transport Security?
It is easy to track down all occurring errors in this log (not too hard to look for an error code).
In this way I was easily able to see what connections were being established and maybe failed, due to load limitations (of course, good software engineers know by heart ;) )
Any kind of third party tracker or the own network setup is running just fine, despite from Google Analytics.
At first I downloaded the last Example codes and had a look at them, of course you cannot expect a library to already support most recent beta systems, nevertheless, I gave it a try. And it failed as soon as the NSAllowsArbitraryLoads is set to false/NO
Even with limiting as few as possible for the third party I was not able to make it run:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>ssl.google-analytics.com</key>
<dict>
<key>NSRequiresCertificateTransparency</key>
<true/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
Also tried google-analytics.com and to include subdomains NSIncludesSubdomains:true. And, as the simple website call in browser of "https://google-analytics.com" redirects to "https://www.google.com/analytics/" I also tried to allow google.com as additional exception domain, which also fails.
Even had a look at the supported ssl-ciphers, I think they are no problem here:
nmap --script ssl-enum-ciphers -p 443 ssl.google-analytics.com
| TLSv1.2:
| ciphers:
| TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA (dh 256) - C
| TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (dh 256) - A
| TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (dh 256) - A
| TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (dh 256) - A
| TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (dh 256) - A
| TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 (dh 256) - A
| TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (dh 256) - A
| TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (dh 256) - A
| TLS_ECDHE_RSA_WITH_RC4_128_SHA (dh 256) - A
| TLS_RSA_WITH_3DES_EDE_CBC_SHA (rsa 2048) - C
| TLS_RSA_WITH_AES_128_CBC_SHA (rsa 2048) - A
| TLS_RSA_WITH_AES_128_CBC_SHA256 (rsa 2048) - A
| TLS_RSA_WITH_AES_128_GCM_SHA256 (rsa 2048) - A
| TLS_RSA_WITH_AES_256_CBC_SHA (rsa 2048) - A
| TLS_RSA_WITH_AES_256_CBC_SHA256 (rsa 2048) - A
| TLS_RSA_WITH_AES_256_GCM_SHA384 (rsa 2048) - A
| TLS_RSA_WITH_RC4_128_MD5 (rsa 2048) - A
| TLS_RSA_WITH_RC4_128_SHA (rsa 2048) - A
So, the google analytics tracking still fails for requests like:
https://ssl.google-analytics.com/collect?[....]
Has anyone come up with a solution or maybe found some kind of mistake in my approach?
Actually the above configuration was slightly wrong, I found a working approach.
-- Short story start --
Basically, the above approach was mostly correct, but I came up to check the configuration again, when I had a look at the established network connection from Mac OS 10.10 and OS 10.11
openssl s_client -connect ssl.google-analytics.com:443 -status
Mac OS 10.10 made use of TLSv1.2, while Mac OS 10.11 for whatever reason used TLSv1.0
-- Short story end --
So, after rethinking the attributes, I removed the Certificate transparency NSRequiresCertificateTransparency, as the default is also set to be false and not true. The following configuration now works for me:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>ssl.google-analytics.com</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
Additional note: although google makes use of this "experimental standard" (certificate transparency):https://en.wikipedia.org/wiki/Certificate_Transparency
It seems to not make use of it in google analytics :-)

iOS .stringsdict not working

I'm trying to use the .stringsdict functionality in iOS programming to display the proper ordinal suffix (st, nd, rd, etc...) for numbers. I've created the .stringsdict file for english, but it's only using the 'one' and 'other' keys. It's ignoring the 'two' and 'few' options. Anybody see what i've done wrong here?
The file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>TEAM_RANK_ORDINAL</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%##ordinal_string#</string>
<key>ordinal_string</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lu</string>
<key>one</key>
<string>%lust</string>
<key>two</key>
<string>%lund</string>
<key>few</key>
<string>%lurd</string>
<key>other</key>
<string>%luth</string>
</dict>
</dict>
</dict>
</plist>
I then access it like so, from Swift. For the value 1 it appends st, but every other number appends th:
let fmt = NSLocalizedString("TEAM_RANK_ORDINAL", comment: "")
for i in 0...30 {
println(String(format: fmt, i))
}
The english locale ignores the "two" and "few" rules and uses
only "one" and "other".
See Plural Rule Properties in the "Internationalization and Localization Guide":
The meaning of the categories is language-dependent, and not all
languages have the same categories.
For example, English only uses the one, and other categories to
represent plural forms. Arabic has different plural forms for the
zero, one, two, few, many, and other categories. ...
There is (as far as I know) no way to use a .stringsdict file
for producing ordinal numbers.
While Martin answered your stringsdict question, for users who stumble across the "ordinal" issue, one should just use NumberFormatter for localized ordinal numbers. E.g.
let formatter = NumberFormatter()
formatter.numberStyle = .ordinal
for i in 1..<30 {
print(formatter.string(for: i) ?? i)
}
Producing (for English users):
1st
2nd
3rd
4th
5th
6th
7th
8th
9th
10th
11th
12th
13th
14th
15th
16th
17th
18th
19th
20th
21st
22nd
23rd
24th
25th
26th
27th
28th
29th
And, FWIW, even if the stringsdict approach worked for two, etc., doesn't have a prayer of differentiating between large numbers that use a different ordinality syntax, e.g. between 122nd and 124th. You really need to use NumberFormatter for this.

xcode doesn't show my plist file that has more than 15k lines

I have a plist that has more than 15k lines, that I generate through my python script. If I limit it to 100 lines, xcode opens the plist without any error, but if I open the 15k+ plist xcode says:
The data couldn't be read because it isn't in the correct format
So does xcode has a limit on plist files with a large number of lines? Else I cant explain why this error comes on only the big number file..
I had this same problem in my plist; for me the issue was an & in a <string> value.
My fix was to escape & with & in my plist. (& needs to be escaped in XML)
Background on my issue: I'm storing escaped HTML as string values in my plist, escaping < and > with < and > respectively. But there were URLs in my HTML with the & char that needed to be escaped as well.

Resources