Skip to content

Commit

Permalink
new:(*) localization
Browse files Browse the repository at this point in the history
  • Loading branch information
niyongsheng committed Feb 7, 2024
1 parent 4901b42 commit b250034
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 69 deletions.
1 change: 0 additions & 1 deletion Examples/Objective-C/NYSExampleObjC/AppManager/DBManager.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//
// DBManager.h
// NYSExampleObjC
//
// Created by 倪永胜 on 2020/7/18.
// Copyright © 2020 niyongsheng. All rights reserved.
Expand Down
13 changes: 6 additions & 7 deletions Examples/Objective-C/NYSExampleObjC/AppManager/DBManager.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//
// DBManager.m
// NYSExampleObjC
//
// Created by 倪永胜 on 2020/7/18.
// Copyright © 2020 niyongsheng. All rights reserved.
Expand Down Expand Up @@ -43,7 +42,7 @@ - (FMDatabaseQueue *)dbQueue {
- (void)createTableWithSQL:(NSString *)sql {

[self.dbQueue inDatabase:^(FMDatabase *db) {
BOOL result = [db executeUpdate:sql withArgumentsInArray:nil];
BOOL result = [db executeUpdate:sql withArgumentsInArray:@[]];
if (result) {
NLog(@"创建表格成功");
} else {
Expand All @@ -56,7 +55,7 @@ - (void)createTableWithSQL:(NSString *)sql {
- (void)dropTableWithSQL:(NSString *)sql {

[self.dbQueue inDatabase:^(FMDatabase *db) {
BOOL result = [db executeUpdate:sql withArgumentsInArray:nil];
BOOL result = [db executeUpdate:sql withArgumentsInArray:@[]];
if (result) {
NLog(@"删除表格成功");
} else {
Expand All @@ -69,7 +68,7 @@ - (void)dropTableWithSQL:(NSString *)sql {
- (void)insertDataWithSQL:(NSString *)sql {

[self.dbQueue inDatabase:^(FMDatabase *db) {
BOOL result = [db executeUpdate:sql withArgumentsInArray:nil];
BOOL result = [db executeUpdate:sql withArgumentsInArray:@[]];
if (result) {
NLog(@"插入数据成功");
} else {
Expand All @@ -84,7 +83,7 @@ - (void)queryAll {
[self.dbQueue inDatabase:^(FMDatabase *db) {
NSString *sql = @"select * from T_human";

FMResultSet *resultSet = [db executeQuery:sql withArgumentsInArray:nil];
FMResultSet *resultSet = [db executeQuery:sql withArgumentsInArray:@[]];

while (resultSet.next) {
NSString *name = [resultSet stringForColumn:@"name"];
Expand Down Expand Up @@ -118,8 +117,8 @@ - (void)transaction {
NSString *sql = @"insert into T_human(name, age, height) values('wangwu', 15, 170);insert into T_human(name, age, height) values('zhaoliu', 13, 160);";
NSString *sql2 = @"insert into T_human(name, age, height) values('zhaoliu', 13, 160);insert into T_human(name, age, height) values('wangwu', 15, 170);";

BOOL result1 = [db executeUpdate:sql withArgumentsInArray:nil];
BOOL result2 = [db executeUpdate:sql2 withArgumentsInArray:nil];
BOOL result1 = [db executeUpdate:sql withArgumentsInArray:@[]];
BOOL result2 = [db executeUpdate:sql2 withArgumentsInArray:@[]];

if (result1 && result2) {
NLog(@"执行成功");
Expand Down
4 changes: 4 additions & 0 deletions Examples/Swift/NYSExampleSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
C893E3EE2B5F552F0087AB36 /* NYSTextAlertView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C893E3ED2B5F552F0087AB36 /* NYSTextAlertView.xib */; };
C8958BB02B6B5FE400693DAE /* NYSPreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8958BAE2B6B5FE400693DAE /* NYSPreviewViewController.swift */; };
C8958BB12B6B5FE400693DAE /* NYSPreviewViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C8958BAF2B6B5FE400693DAE /* NYSPreviewViewController.xib */; };
C89E827B2B731986002BEC52 /* AppDelegate+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89E827A2B731986002BEC52 /* AppDelegate+Extension.swift */; };
C8A00F272B464CBD00245D94 /* Transform.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8A00F262B464CBD00245D94 /* Transform.swift */; };
C8A4BE292B4B99E500152E14 /* system.style in Resources */ = {isa = PBXBuildFile; fileRef = C8A4BE282B4B99E400152E14 /* system.style */; };
C8A4BE2B2B4B9E5600152E14 /* NYSHomeListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8A4BE2A2B4B9E5600152E14 /* NYSHomeListCell.swift */; };
Expand Down Expand Up @@ -223,6 +224,7 @@
C893E3ED2B5F552F0087AB36 /* NYSTextAlertView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NYSTextAlertView.xib; sourceTree = "<group>"; };
C8958BAE2B6B5FE400693DAE /* NYSPreviewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NYSPreviewViewController.swift; sourceTree = "<group>"; };
C8958BAF2B6B5FE400693DAE /* NYSPreviewViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NYSPreviewViewController.xib; sourceTree = "<group>"; };
C89E827A2B731986002BEC52 /* AppDelegate+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Extension.swift"; sourceTree = "<group>"; };
C8A00F262B464CBD00245D94 /* Transform.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Transform.swift; sourceTree = "<group>"; };
C8A4BE282B4B99E400152E14 /* system.style */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = system.style; sourceTree = "<group>"; };
C8A4BE2A2B4B9E5600152E14 /* NYSHomeListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NYSHomeListCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -442,6 +444,7 @@
C8597AC929F522D9008BEE7F /* PrefixHeader.pch */,
C8621DEC2B3182EE00F90DF0 /* Bridging-Header.h */,
C8597A8129F5119E008BEE7F /* AppDelegate.swift */,
C89E827A2B731986002BEC52 /* AppDelegate+Extension.swift */,
C8597A8529F5119E008BEE7F /* ViewController.swift */,
C8597A8729F5119E008BEE7F /* Main.storyboard */,
C8597A8C29F511A0008BEE7F /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -1032,6 +1035,7 @@
C8474E532B43DD54001DE04A /* NYSRootViewController.swift in Sources */,
C8958BB02B6B5FE400693DAE /* NYSPreviewViewController.swift in Sources */,
C83162A72B4CE5160014CFE1 /* UIScrollView+RxSwift.swift in Sources */,
C89E827B2B731986002BEC52 /* AppDelegate+Extension.swift in Sources */,
C85D7E7C2B60F34300C4BC93 /* NYSImageItemView.swift in Sources */,
C8ED6DDB2B51494D000F2268 /* NYSRootWebViewController.swift in Sources */,
C8ED6DE02B550A61000F2268 /* NYSRootCodable.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// AppDelegate+Extension.swift
// NYSExampleSwift
//
// Created by niyongsheng on 2024/2/7.
// Copyright © 2024 niyongsheng. All rights reserved.
//

import Foundation

extension AppDelegate: JPUSHRegisterDelegate, JPUSHInAppMessageDelegate {

func initJPush(_ launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
let entity = JPUSHRegisterEntity()
entity.types = NSInteger(UNAuthorizationOptions.alert.rawValue) |
NSInteger(UNAuthorizationOptions.sound.rawValue) |
NSInteger(UNAuthorizationOptions.badge.rawValue) |
NSInteger(UNAuthorizationOptions.provisional.rawValue)

JPUSHService.register(forRemoteNotificationConfig: entity, delegate: self)
JPUSHService.setInAppMessageDelegate(self)
JPUSHService.setup(withOption: launchOptions, appKey: JPUSH_APPKEY, channel: JPUSH_CHANNEl, apsForProduction: IS_Prod, advertisingIdentifier: nil)
JPUSHService.registrationIDCompletionHandler { resCode, registrationID in
if resCode == 0 {
self.print("registrationID获取成功:\(String(describing: registrationID))")
} else {
self.print("registrationID获取失败,code:\(String(describing: registrationID))")
}
}
}

// MARK - JPUSHRegisterDelegate
func jpushNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: (() -> Void)) {
let userInfo = response.notification.request.content.userInfo
let request = response.notification.request
if (response.notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self) == true) {
JPUSHService.handleRemoteNotification(userInfo)
}
print(request)
completionHandler()
}

// 前台得到的的通知
func jpushNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: ((Int) -> Void)) {
let userInfo = notification.request.content.userInfo
let request = notification.request
if (notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self) == true) {
JPUSHService.handleRemoteNotification(userInfo)
}
print(request)
completionHandler(Int(UNNotificationPresentationOptions.badge.rawValue | UNNotificationPresentationOptions.sound.rawValue | UNNotificationPresentationOptions.alert.rawValue))
}

func jpushNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification) {

}

func jpushNotificationAuthorization(_ status: JPAuthorizationStatus, withInfo info: [AnyHashable : Any]?) {
print("receive notification authorization status:\(status), info:\(String(describing: info))")
}

// MARK - JPushInMessageDelegate
func jPush(inAppMessageDidShow inAppMessage: JPushInAppMessage) {

}

func jPush(inAppMessageDidClick inAppMessage: JPushInAppMessage) {

}
}
61 changes: 0 additions & 61 deletions Examples/Swift/NYSExampleSwift/Supporting Files/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,64 +142,3 @@ extension AppDelegate {
#endif
}
}

extension AppDelegate: JPUSHRegisterDelegate, JPUSHInAppMessageDelegate {

func initJPush(_ launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
let entity = JPUSHRegisterEntity()
entity.types = NSInteger(UNAuthorizationOptions.alert.rawValue) |
NSInteger(UNAuthorizationOptions.sound.rawValue) |
NSInteger(UNAuthorizationOptions.badge.rawValue) |
NSInteger(UNAuthorizationOptions.provisional.rawValue)

JPUSHService.register(forRemoteNotificationConfig: entity, delegate: self)
JPUSHService.setInAppMessageDelegate(self)
JPUSHService.setup(withOption: launchOptions, appKey: JPUSH_APPKEY, channel: JPUSH_CHANNEl, apsForProduction: IS_Prod, advertisingIdentifier: nil)
JPUSHService.registrationIDCompletionHandler { resCode, registrationID in
if resCode == 0 {
self.print("registrationID获取成功:\(String(describing: registrationID))")
} else {
self.print("registrationID获取失败,code:\(String(describing: registrationID))")
}
}
}

// MARK - JPUSHRegisterDelegate
func jpushNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: (() -> Void)) {
let userInfo = response.notification.request.content.userInfo
let request = response.notification.request
if (response.notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self) == true) {
JPUSHService.handleRemoteNotification(userInfo)
}
print(request)
completionHandler()
}

// 前台得到的的通知
func jpushNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: ((Int) -> Void)) {
let userInfo = notification.request.content.userInfo
let request = notification.request
if (notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self) == true) {
JPUSHService.handleRemoteNotification(userInfo)
}
print(request)
completionHandler(Int(UNNotificationPresentationOptions.badge.rawValue | UNNotificationPresentationOptions.sound.rawValue | UNNotificationPresentationOptions.alert.rawValue))
}

func jpushNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification) {

}

func jpushNotificationAuthorization(_ status: JPAuthorizationStatus, withInfo info: [AnyHashable : Any]?) {
print("receive notification authorization status:\(status), info:\(String(describing: info))")
}

// MARK - JPushInMessageDelegate
func jPush(inAppMessageDidShow inAppMessage: JPushInAppMessage) {

}

func jPush(inAppMessageDidClick inAppMessage: JPushInAppMessage) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NoMore="No más";
NoData="No Data";
NetErr="Error de red";
Retry="reintentar";
Loading="Carga...";

TipsAppUpdate="Nueva versión de prueba";
AppUpdate="actualización";
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NoMore="もう";
NoData="データがない";
NetErr="ネットワーク誤差";
Retry="再審";
Loading="装着…";

TipsAppUpdate="新テスト版";
AppUpdate="更新";
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NoMore="더 이상";
NoData="데이터 가 없";
NetErr="네트워크 오류 가";
Retry="재시도";
Loading="로드 …";

TipsAppUpdate="New 테스트 버전";
AppUpdate="업 데이트";

0 comments on commit b250034

Please sign in to comment.