I had some support tickets about dates not showing properly for customers based in the America/Merida timezone.
Essentially America/Merida permanently changed to -0500 (CDT) on October 31, 2021, and it appears that the NSTimeZone does not respect this change, and reports times as -0600 (CST).
Creating a little test tool with the following code:
+(void) run {
NSArray<NSString *> * args = [[NSProcessInfo processInfo] arguments];
if ([args count] > 1) {
NSString *timezone = args[1];
NSLog(@"custom TZ: %@", timezone);
NSTimeZone * tz = [NSTimeZone timeZoneWithName:timezone];
[NSTimeZone setDefaultTimeZone:tz];
}
NSDate * now = [NSDate date];
NSLog(@"Testing Dates: (local timezone : %@)", [NSTimeZone localTimeZone]);
NSLog(@" (default timezone: %@)", [NSTimeZone defaultTimeZone]);
NSLog(@" (is DST : %@)", [[NSTimeZone defaultTimeZone] isDaylightSavingTimeForDate:now] ? @"YES" : @"NO");
NSLog(@" (current cal-tz : %@)", [[NSCalendar currentCalendar] timeZone]);
NSLog(@" (current locale : %@)", [[NSLocale currentLocale] localeIdentifier]);
NSLog(@"Now: %@", now);
}
And running with the America/Merida timezone passed in, I'm getting the following output:
custom TZ: America/Merida
Testing Dates: (local timezone : Local Time Zone (America/New_York (EDT) offset -14400 (Daylight)))
(default timezone: America/Merida (CST) offset -21600)
(is DST : NO)
(current cal-tz : America/Merida (CST) offset -21600)
(current locale : en_US)
Now: Tue May 14 15:06:14 2024
Running the same code on Linux via the GNUStep implementation of Objective-C, I get the correct output with America/Merida showing up as CDT (ie (is DST : YES)).
Are there any good ways to work around this?
Post not yet marked as solved
My app downloads files from AWS S3. What we'd like to do is replicate our files across several of Amazon's data centers (regions) to put the content closer to our users, who are worldwide.
What I need is a way to determine in a very ***** way which data center would be best to use. For example North America, Europe, Asia, etc. I don't want to use location services since I don't really need the exact location. Is there a simpler way to do this?
I suppose I could use the localization settings, but I don't think that's really guaranteed to represent their actual location.
Thanks,
Frank
Post not yet marked as solved
I want to change the display language, particularly for week and the year and date on MultiDatePicker.
By adjusting the locale, the year and date can be changed.
However, I'm unable to change the display for week .
I've tried several methods, such as setting the calendar and adjusting the time zone, but none of them seem to work.
Are there any good way to solve it?
Post not yet marked as solved
I have a macOS application with a minimum version of macOS 12.0. I need to be able to get the current keyboard region designator.
Example: The user selects a input source of English Canadian. What I want as a result of this fact is en-CA locale identifier.
I get the current keyboard language with the following code
func keyboardLanguage() -> String?{
let keyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()
let languagesPtr = TISGetInputSourceProperty(keyboard, kTISPropertyInputSourceLanguages)!
let languages = Unmanaged<AnyObject>.fromOpaque(languagesPtr).takeUnretainedValue() as? [String]
return languages?.first
}
This returns the language as en, but I don't see how I can get the region from Text Input Sources. I can get the input source id
let keyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()
let idPtr = TISGetInputSourceProperty(keyboard, kTISPropertyInputSourceID)!
let id = Unmanaged<AnyObject>.fromOpaque(idPtr).takeUnretainedValue() as? String
print(String(describing: id))
This prints com.apple.keylayout.Canadian which points to the Canadian region but is not a region designator. I can possible parse this id and map it to a region designator but first I'm not sure if I will capture all of the regions and secondly what happens if the format of the id changes? If someone can point to the correct API to use it will be much appreciated.
Post not yet marked as solved
My app is only available in some regions.
During one of the review versions, the reviewer asked to remove accessibility from one of the countries or provide documents that allow to conduct activities in this country.
At that time, there was no such document and I removed the availability in this country.
Now - I have a document that confirms that I can conduct activities in this country. Availability is a separate section and is not related to versioning.
How and where do I request app availability in a specific country?
Post not yet marked as solved
I have encountered inconsistent paste behaviors in UITextView depending on whether the text is in English or Korean.
When pasting at the beginning of a text with an English sentence in UITextView, a space is added after the pasted text. In the middle, spaces are added before and after the pasted text. However, when pasting at the end, only a space is added before the pasted text.
On the other hand, when there is a Korean sentence in UITextView, pasting at the beginning results in the inclusion of "\n" at the beginning of the pasted text, while in other cases, no additional text is added upon pasting.
I'm curious to know if this behavior is intentional. I would appreciate understanding the rationale behind appending "\n" in Korean text and the absence of additional text in other cases.
Post not yet marked as solved
I am developing a web application that works on webview.
From iOS 13, users could set a specific language for each individual app, and every webview-based application knew the application language through navigator.language.
However, in iOS 17.4, this API returns the system language instead of the individual app's language in web applications.
Is this an official change in iOS 17.4 or a bug?
Post not yet marked as solved
Application:
HTML,Javascript,Angular web Application
Issue:
In Iphone/Ipad while trying to enter English characters using Japanese keyboard in the input field
the japanese keyboard freezes and stops working after entering the first character.
Root Cause:
Two validations given in the onInput call back method causes the issue.
when the validation are removed keyboard is working fine
1.for converting lowercase letters to uppercase
2.Some Character are not allowed so they are replaced after input
Post not yet marked as solved
Hello, I have an issue with formatting text in a TextField. I want to maintain formatting to two decimal places and have it respond to changes in the device's settings, as it currently does. However, I want to get rid of the problem with deleting the first character, which for some reason cannot be empty even though it should start with an empty value.
This is my code
extension Formatter {
static let numberFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.currencyCode = "GBP"
formatter.currencySymbol = ""
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2
formatter.zeroSymbol = ""
return formatter
}()
}
struct HomeView: View {
@FocusState private var isFocused: Bool
@State var value: Double = 0
var body: some View {
VStack {
TextField("0.0",
value: $value,
formatter: Formatter.numberFormatter)
.focused($isFocused)
.border(.red)
.keyboardType(.decimalPad)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
if isFocused {
Spacer()
Button("Done") {
isFocused = false
}
}
}
}
}
}
}
and here is the issue gif
I found similar problems in other forums like in https://www.hackingwithswift.com/forums/swiftui/textfield-with-initial-empty-value-for-a-number/12486/15516 but unfortunately uncomment.
Post not yet marked as solved
I have an localized iOS App from which I want to obtain the device language (not the app language). The following sample app is localized in English and German. The current app language is German.
Here I want to obtain english, since that's the device language (see next screenshot).
Device Language Settings:
App Language Settings: (shouldn't be considered for obtaining device language)
Is there any API I could use to retrieve the device language?
To obtain the device language is a product management requirement to derive next steps in the app localization process.
Code of sample App:
struct ContentView: View {
var body: some View {
Form {
Text("Hello, world")
Text("Locale.preferredLanguages:\n\(Locale.preferredLanguages.joined(separator: ", "))")
Text("Locale.current:\n\(Locale.current.language.languageCode?.identifier ?? "")")
}
}
}
Note: I have asked this question on Stack Overflow too (see here)
Post not yet marked as solved
I just wasted quite a lot of time on this .. so in case somebody else checks in here, beware that the following:
formatted(dateTime.hour(.defaultDigits(amPM: .omitted)))
does, indeed omit AM/PM, but it doesn't change to using a 24 hour clock. Instead, hours cycle through 1...12 twice a day.
Post not yet marked as solved
I am working on an app that pulls data from weatherKit, including the conditionCode property, the content of which is displayed to the user. I wish to localize the data pulled from weatherKit but when pulling data from:
weatherkit.apple.com/api/v1/weather/de/{latitude}/{longitude}
The conditionCode and other strings is in english. Same is true if the language parameter is set to es, ja or something else.
Am I doing something wrong or is localization yet to be supported in weatherKit? I can't find any documentation on this.
Post not yet marked as solved
Does anyone have the format string to use to just get the 24 hour time (no am/pm) indicator from Date?
I can't seem to get 24 hour time with:
let now = Date()
now.formatted(date:.omitted,time:.complete) // Or any of the time options.
Post not yet marked as solved
let formatter = DateIntervalFormatter()
formatter.dateStyle = .none
formatter.timeStyle = .none
formatter.dateTemplate = "EEEjm"
Produces, in my locale and on my device with 24 hour time on:
"Tue, 6:39 – 7:10 pm"
I was expecting:
"Tue, 18:39 – 19:10"
Other date formatters are showing 24 hour time using the j symbol. For example:
let formatter = DateFormatter()
formatter.dateStyle = .none
formatter.timeStyle = .none
formatter.setLocalizedDateFormatFromTemplate("EEEjm")
Produces, for the start and end dates:
Tue 18:39
Tue 19:10
Further, NSDateIntervalFormatter.h suggests I should be able to use symbols like j.
So why can't I create strings in 24 hour time with DateIntervalFormatter?
Thanks for your time.
iOS 16.7.1 / Xcode 15
Post not yet marked as solved
We want to implement Serbian (latin) language in our app. The idea is pretty simple: if user device's preferred language is Serbian (no matter, latin or cyrillic) – we use Serbian latin, which we have in our app.
The problem is that it looks like this idea is unimplementable. If we use sr_Latn as code for Serbian latin in our Info.plist, and device's preferred language is just Serbian (which is Cyrillic in iOS) – the fallback in app will be English (default language), not Serbian latin.
Reverse is the same: if we implement Serbian latin as sr (just Serbian), then user select Serbian latin (sr_Latn) as device's preferred language – then app language will be English, not Serbian.
In the source code published on one of the forum's answer I see that it is expected fallback (unfortunately undocumented). This code is old one, but looks like behavior still persist.
Is there any way to implement one Serbian for all cases?
I am seeing the following log in the console in Xcode Version 15.0.1 (15A507):
Cannot use inflection engine (Checking that the token is the correct type):
I am able to reproduce the issue using Apple's own sample code, "Building a Localized Food-Ordering App" associated with WWDC21 Session 10109: What's New In Foundation, simply by building and running the sample code.
That log message immediately appears a few times in the console when running that sample project.
I'm assuming given it is happening in Apple's own sample project, that this is merely console noise and basically something out of my control.
Post not yet marked as solved
I have the following requirement for my project:
The app localization is currently based on static string JSON files. However, I would like to dynamically update strings upon an API call. Is it possible to update the resource files mentioned above after receiving a response from the API? If not, can I create a custom bundle to store new translations? Additionally, where should I create the custom bundle, specifying the path or location?
Post not yet marked as solved
I noticed the output when running the following on different mac dev machines.
Anyone know more detail on this?
let formatter = DateComponentsFormatter()
formatter.allowedUnits = [.hour, .minute, .second]
formatter.unitsStyle = .brief
the output changed from
233hr 55min 35secs
to
233hrs 55min 35secs
on another machine,
the output is
233hrs 55min. 35secs.
Thanks in advance!
Post not yet marked as solved
Our application should support locales for Albanian and Albanian(Kosovo). Xcode creates sq.lproj and sq-XK.lproj folders accordingly
Everything works fine in xcode, but if we upload to appstore we always see this warning. I tried specifying other names for sq-XK to match https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html aln, sq-RS, sq-KV, sq-KS, sq-Latn-XQ. The varning was always present. Is there any way to get rid of it?
WARNING ITMS-90176: "Unrecognized Locale - The locale used in localization directories at ("Payload/{AppName}.app/base.lproj") are invalid. iTunes supports BCP47 but not the UN M.49 specification. Refer to the Language and Locale Designations guide for more information on naming your language-specific directories."
Post not yet marked as solved
Hello folks!
I am looking into how to personalize my app based on iPhone user preferred term of address using TermOfAddress API (1, 2).
If I understand correctly, to use the API for personalization purposes the app should know user's selection (masculine, feminine, neuter).
What I don't understand is whether there is an API allowing to get user term of address which they set in their iPhone settings for 3P apps.
So the flow I am thinking of is:
User sets their preferred term of address in device settings
My app somehow is able to retrieve it and use TermsOfAddress concept to serve proper message in Spanish ("Bienvenido a mi aplicación!" for masculine vs "Bienvenida a mi aplicación!" for feminine vs "Les doy la bienvenida a mi aplicación" for neutral).
Apple support docs say
"Your preferred form of address. (Choose feminine, masculine, or neutral. Turn on Share with All Apps so all apps personalize how they address you. Available for some primary languages, for example, Spanish.)".
So I assume that there is a way for apps to retrieve this information.
But I can't find any API for that.
Any thoughts on this? I wonder if "Share with all apps" means "Share with all 1P apps" and 3P apps can not use it (which means I have to ask user for their term of address from my app)?
Thanks!