Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit e82d9b9

Browse files
Merge pull request #103 from wordpress-mobile/issue/86-explicit-locale-handling
Modified existing services to leverage locale handling
2 parents 1536482 + 131edbe commit e82d9b9

10 files changed

+7
-31
lines changed

WordPressKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressKit"
3-
s.version = "2.1.1-beta.2"
3+
s.version = "3.0.0-beta.1"
44
s.summary = "WordPressKit offers a clean and simple WordPress.com and WordPress.org API."
55

66
s.description = <<-DESC

WordPressKit/AccountServiceRemoteREST.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ - (void)requestWPComMagicLinkForEmail:(NSString *)email
242242
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:@{
243243
@"email": email,
244244
@"client_id": clientID,
245-
@"client_secret": clientSecret,
246-
@"locale": [[WordPressComLanguageDatabase new] deviceLanguageSlug],
245+
@"client_secret": clientSecret
247246
}];
248247
if (![@"wordpress" isEqualToString:scheme]) {
249248
[params setObject:scheme forKey:@"scheme"];

WordPressKit/ActivityServiceRemote.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ public class ActivityServiceRemote: ServiceRemoteWordPressComREST {
2626
failure: @escaping (Error) -> Void) {
2727
let endpoint = "sites/\(siteID)/activity"
2828
let path = self.path(forEndpoint: endpoint, withVersion: ._2_0)
29-
let locale = WordPressComLanguageDatabase().deviceLanguage.slug
3029
let pageNumber = (offset / count + 1)
3130
let parameters: [String: AnyObject] = [
32-
"locale": locale as AnyObject,
3331
"number": count as AnyObject,
3432
"page": pageNumber as AnyObject
3533
]
@@ -64,13 +62,9 @@ public class ActivityServiceRemote: ServiceRemoteWordPressComREST {
6462
failure: @escaping (Error) -> Void) {
6563
let endpoint = "sites/\(siteID)/rewind"
6664
let path = self.path(forEndpoint: endpoint, withVersion: ._2_0)
67-
let locale = WordPressComLanguageDatabase().deviceLanguage.slug
68-
let parameters: [String: AnyObject] = [
69-
"locale": locale as AnyObject
70-
]
7165

7266
wordPressComRestApi.GET(path,
73-
parameters: parameters,
67+
parameters: nil,
7468
success: { response, _ in
7569
guard let rewindStatus = response as? [String: AnyObject] else {
7670
failure(ResponseError.decodingFailure)

WordPressKit/PlanServiceRemote.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ public class PlanServiceRemote: ServiceRemoteWordPressComREST {
1919
public func getWpcomPlans(_ success: @escaping (AvailablePlans) -> Void, failure: @escaping (Error) -> Void) {
2020
let endpoint = "plans/mobile"
2121
let path = self.path(forEndpoint: endpoint, withVersion: ._2_0)
22-
let locale = WordPressComLanguageDatabase().deviceLanguage.slug
23-
let parameters = ["locale": locale]
2422

2523
wordPressComRestApi.GET(path,
26-
parameters: parameters as [String : AnyObject]?,
24+
parameters: nil,
2725
success: {
2826
response, _ in
2927

WordPressKit/PlanServiceRemote_ApiVersion1_3.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ import CocoaLumberjack
1111
failure: @escaping (Error) -> Void) {
1212
let endpoint = "sites/\(siteID)/plans"
1313
let path = self.path(forEndpoint: endpoint, withVersion: ._1_3)
14-
let locale = WordPressComLanguageDatabase().deviceLanguage.slug
15-
let parameters = ["locale": locale]
14+
1615
wordPressComRestApi.GET(
1716
path,
18-
parameters: parameters as [String : AnyObject]?,
17+
parameters: nil,
1918
success: {
2019
response, _ in
2120
do {

WordPressKit/ReaderSiteSearchServiceRemote.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ public class ReaderSiteSearchServiceRemote: ServiceRemoteWordPressComREST {
2525
failure: @escaping (Error) -> Void) {
2626
let endpoint = "read/feed"
2727
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)
28-
let locale = WordPressComLanguageDatabase().deviceLanguage.slug
2928
let parameters: [String: AnyObject] = [
30-
"locale": locale as AnyObject,
3129
"number": count as AnyObject,
3230
"offset": offset as AnyObject,
3331
"exclude_followed": false as AnyObject,

WordPressKit/TimeZoneServiceRemote.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ public class TimeZoneServiceRemote: ServiceRemoteWordPressComREST {
99
public func getTimezones(success: @escaping (([TimeZoneGroup]) -> Void), failure: @escaping ((Error) -> Void)) {
1010
let endpoint = "timezones"
1111
let path = self.path(forEndpoint: endpoint, withVersion: ._2_0)
12-
let locale = WordPressComLanguageDatabase().deviceLanguage.slug
13-
let parameters: [String: AnyObject] = ["_locale": locale as AnyObject]
14-
wordPressComRestApi.GET(path, parameters: parameters, success: { (response, _) in
12+
wordPressComRestApi.GET(path, parameters: nil, success: { (response, _) in
1513
do {
1614
let groups = try self.timezoneGroupsFromResponse(response)
1715
success(groups)

WordPressKit/WordPressComServiceRemote.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ typedef void(^WordPressComServiceFailureBlock)(NSError *error);
2222
* @param email The email to use for the new account. Cannot be nil.
2323
* @param username The username of the new account. Cannot be nil.
2424
* @param password The password of the new account. Cannot be nil.
25-
* @param locale The locale for the new account. Cannot be nil.
2625
* @param success The block to execute on success. Can be nil.
2726
* @param failure The block to execute on failure. Can be nil.
2827
*/
2928
- (void)createWPComAccountWithEmail:(NSString *)email
3029
andUsername:(NSString *)username
3130
andPassword:(NSString *)password
32-
andLocale:(NSString *)locale
3331
andClientID:(NSString *)clientID
3432
andClientSecret:(NSString *)clientSecret
3533
success:(WordPressComServiceSuccessBlock)success
@@ -45,7 +43,6 @@ typedef void(^WordPressComServiceFailureBlock)(NSError *error);
4543
@param failure failure block
4644
*/
4745
- (void)createWPComAccountWithGoogle:(NSString *)token
48-
andLocale:(NSString *)locale
4946
andClientID:(NSString *)clientID
5047
andClientSecret:(NSString *)clientSecret
5148
success:(WordPressComServiceSuccessBlock)success

WordPressKit/WordPressComServiceRemote.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ @implementation WordPressComServiceRemote
88
- (void)createWPComAccountWithEmail:(NSString *)email
99
andUsername:(NSString *)username
1010
andPassword:(NSString *)password
11-
andLocale:(NSString *)locale
1211
andClientID:(NSString *)clientID
1312
andClientSecret:(NSString *)clientSecret
1413
success:(WordPressComServiceSuccessBlock)success
@@ -21,7 +20,6 @@ - (void)createWPComAccountWithEmail:(NSString *)email
2120
[self createWPComAccountWithEmail:email
2221
andUsername:username
2322
andPassword:password
24-
andLocale:locale
2523
andClientID:clientID
2624
andClientSecret:clientSecret
2725
validate:NO
@@ -32,7 +30,6 @@ - (void)createWPComAccountWithEmail:(NSString *)email
3230
- (void)createWPComAccountWithEmail:(NSString *)email
3331
andUsername:(NSString *)username
3432
andPassword:(NSString *)password
35-
andLocale:(NSString *)locale
3633
andClientID:(NSString *)clientID
3734
andClientSecret:(NSString *)clientSecret
3835
validate:(BOOL)validate
@@ -57,7 +54,6 @@ - (void)createWPComAccountWithEmail:(NSString *)email
5754
@"username": username,
5855
@"password": password,
5956
@"validate": @(validate),
60-
@"locale": locale,
6157
@"client_id": clientID,
6258
@"client_secret": clientSecret
6359
};
@@ -70,7 +66,6 @@ - (void)createWPComAccountWithEmail:(NSString *)email
7066

7167
// API v1 POST /users/social/new
7268
- (void)createWPComAccountWithGoogle:(NSString *)token
73-
andLocale:(NSString *)locale
7469
andClientID:(NSString *)clientID
7570
andClientSecret:(NSString *)clientSecret
7671
success:(WordPressComServiceSuccessBlock)success
@@ -89,7 +84,6 @@ - (void)createWPComAccountWithGoogle:(NSString *)token
8984
@"client_id": clientID,
9085
@"client_secret": clientSecret,
9186
@"id_token": token,
92-
@"locale": locale,
9387
@"service": @"google",
9488
@"signup_flow_name": @"social",
9589
};

WordPressKitTests/WordPressComServiceRemoteRestTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class WordPressComServiceRemoteRestTests: XCTestCase {
5353
service.createWPComAccount(withEmail: "fakeEmail",
5454
andUsername: "fakeUsername",
5555
andPassword: "fakePassword",
56-
andLocale: "en",
5756
andClientID: "moo",
5857
andClientSecret: "cow",
5958
success: { (responseObject) in

0 commit comments

Comments
 (0)