no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / xpcom / base / MacHelpers.mm
blob9d53fd5b562df6a1267d24b9c242eaf62c9c87a9
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsString.h"
8 #include "MacHelpers.h"
9 #include "MacStringHelpers.h"
10 #include "nsObjCExceptions.h"
12 #import <Foundation/Foundation.h>
14 namespace mozilla {
16 nsresult GetSelectedCityInfo(nsAString& aCountryCode) {
17   NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
19   // Can be replaced with [[NSLocale currentLocale] countryCode] once we build
20   // with the 10.12 SDK.
21   id countryCode = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];
23   if (![countryCode isKindOfClass:[NSString class]]) {
24     return NS_ERROR_FAILURE;
25   }
27   mozilla::CopyNSStringToXPCOMString((NSString*)countryCode, aCountryCode);
29   NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE);
32 }  // namespace mozilla