├── .gitignore
├── .travis.yml
├── Assets
├── App国际化.xmind
├── collect01.jpg
├── collect02.jpg
├── collect03.jpg
├── collect04.jpg
├── collect05.jpg
├── effect.gif
└── overall.jpg
├── Example
├── HDTranslateModule.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── HDTranslateModule-Example.xcscheme
├── HDTranslateModule.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
├── HDTranslateModule
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── HDAppDelegate.h
│ ├── HDAppDelegate.m
│ ├── HDENViewController.h
│ ├── HDENViewController.m
│ ├── HDExampleSwift.swift
│ ├── HDTranslateDemo.bundle
│ │ ├── en.lproj
│ │ │ └── HDTranslateModule.strings
│ │ └── zh-Hans.lproj
│ │ │ └── HDTranslateModule.strings
│ ├── HDTranslateModule-Info.plist
│ ├── HDTranslateModule-Prefix.pch
│ ├── HDTranslateModule_Example-Bridging-Header.h
│ ├── HDViewController.h
│ ├── HDViewController.m
│ ├── Images.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── UIButtonCell.h
│ ├── UIButtonCell.m
│ ├── UILabelCell.h
│ ├── UILabelCell.m
│ ├── UITextFieldCell.h
│ ├── UITextFieldCell.m
│ ├── UITextViewCell.h
│ ├── UITextViewCell.m
│ ├── en.lproj
│ │ ├── InfoPlist.strings
│ │ ├── LaunchScreen.strings
│ │ └── Localizabless.strings
│ ├── main.m
│ └── zh-Hans.lproj
│ │ ├── InfoPlist.strings
│ │ ├── LaunchScreen.strings
│ │ └── Localizabless.strings
├── Podfile
├── Podfile.lock
├── Pods
│ ├── Local Podspecs
│ │ └── HDTranslateModule.podspec.json
│ ├── Manifest.lock
│ ├── Pods.xcodeproj
│ │ └── project.pbxproj
│ ├── SwiftGen
│ │ ├── CHANGELOG.md
│ │ ├── LICENCE
│ │ ├── README.md
│ │ └── bin
│ │ │ ├── SwiftGen_SwiftGenCLI.bundle
│ │ │ └── Contents
│ │ │ │ ├── Info.plist
│ │ │ │ └── Resources
│ │ │ │ └── templates
│ │ │ │ ├── colors
│ │ │ │ ├── literals-swift4.stencil
│ │ │ │ ├── literals-swift5.stencil
│ │ │ │ ├── swift4.stencil
│ │ │ │ └── swift5.stencil
│ │ │ │ ├── coredata
│ │ │ │ ├── swift4.stencil
│ │ │ │ └── swift5.stencil
│ │ │ │ ├── files
│ │ │ │ ├── flat-swift4.stencil
│ │ │ │ ├── flat-swift5.stencil
│ │ │ │ ├── structured-swift4.stencil
│ │ │ │ └── structured-swift5.stencil
│ │ │ │ ├── fonts
│ │ │ │ ├── swift4.stencil
│ │ │ │ └── swift5.stencil
│ │ │ │ ├── ib
│ │ │ │ ├── scenes-swift4.stencil
│ │ │ │ ├── scenes-swift5.stencil
│ │ │ │ ├── segues-swift4.stencil
│ │ │ │ └── segues-swift5.stencil
│ │ │ │ ├── json
│ │ │ │ ├── inline-swift4.stencil
│ │ │ │ ├── inline-swift5.stencil
│ │ │ │ ├── runtime-swift4.stencil
│ │ │ │ └── runtime-swift5.stencil
│ │ │ │ ├── plist
│ │ │ │ ├── inline-swift4.stencil
│ │ │ │ ├── inline-swift5.stencil
│ │ │ │ ├── runtime-swift4.stencil
│ │ │ │ └── runtime-swift5.stencil
│ │ │ │ ├── strings
│ │ │ │ ├── flat-swift4.stencil
│ │ │ │ ├── flat-swift5.stencil
│ │ │ │ ├── objc-h.stencil
│ │ │ │ ├── objc-m.stencil
│ │ │ │ ├── structured-swift4.stencil
│ │ │ │ └── structured-swift5.stencil
│ │ │ │ ├── xcassets
│ │ │ │ ├── swift4.stencil
│ │ │ │ └── swift5.stencil
│ │ │ │ └── yaml
│ │ │ │ ├── inline-swift4.stencil
│ │ │ │ └── inline-swift5.stencil
│ │ │ └── swiftgen
│ └── Target Support Files
│ │ ├── HDTranslateModule
│ │ ├── HDTranslateModule-Info.plist
│ │ ├── HDTranslateModule-dummy.m
│ │ ├── HDTranslateModule-prefix.pch
│ │ ├── HDTranslateModule-umbrella.h
│ │ ├── HDTranslateModule.debug.xcconfig
│ │ ├── HDTranslateModule.modulemap
│ │ └── HDTranslateModule.release.xcconfig
│ │ ├── Pods-HDTranslateModule_Example
│ │ ├── Pods-HDTranslateModule_Example-Info.plist
│ │ ├── Pods-HDTranslateModule_Example-acknowledgements.markdown
│ │ ├── Pods-HDTranslateModule_Example-acknowledgements.plist
│ │ ├── Pods-HDTranslateModule_Example-dummy.m
│ │ ├── Pods-HDTranslateModule_Example-frameworks.sh
│ │ ├── Pods-HDTranslateModule_Example-resources.sh
│ │ ├── Pods-HDTranslateModule_Example-umbrella.h
│ │ ├── Pods-HDTranslateModule_Example.debug.xcconfig
│ │ ├── Pods-HDTranslateModule_Example.modulemap
│ │ └── Pods-HDTranslateModule_Example.release.xcconfig
│ │ ├── Pods-HDTranslateModule_Tests
│ │ ├── Pods-HDTranslateModule_Tests-Info.plist
│ │ ├── Pods-HDTranslateModule_Tests-acknowledgements.markdown
│ │ ├── Pods-HDTranslateModule_Tests-acknowledgements.plist
│ │ ├── Pods-HDTranslateModule_Tests-dummy.m
│ │ ├── Pods-HDTranslateModule_Tests-umbrella.h
│ │ ├── Pods-HDTranslateModule_Tests.debug.xcconfig
│ │ ├── Pods-HDTranslateModule_Tests.modulemap
│ │ └── Pods-HDTranslateModule_Tests.release.xcconfig
│ │ └── SwiftGen
│ │ ├── SwiftGen.debug.xcconfig
│ │ └── SwiftGen.release.xcconfig
└── Tests
│ ├── Tests-Info.plist
│ ├── Tests-Prefix.pch
│ ├── Tests.m
│ └── en.lproj
│ └── InfoPlist.strings
├── HDTranslateModule.podspec
├── HDTranslateModule
├── Assets
│ ├── .gitkeep
│ └── HDTranslateModule.bundle
│ │ ├── en.lproj
│ │ └── HDTranslateModule.strings
│ │ └── zh-Hans.lproj
│ │ └── HDTranslateModule.strings
└── Classes
│ ├── .gitkeep
│ ├── JDLTAttributedString.h
│ ├── JDLTAttributedString.m
│ ├── JDLTTranslateHook.h
│ ├── JDLTTranslateHook.m
│ ├── JDLTTranslateManager.h
│ ├── JDLTTranslateManager.m
│ ├── JDLTTranslateModule.h
│ ├── JDLTTranslateModule.m
│ └── Python
│ ├── HDTranslateModule_Example
│ ├── HDTranslateModule_Example_cstring.txt
│ ├── HDTranslateModule_Example_cstring_output.json
│ ├── HDTranslateModule_Example_cstring_output_final.json
│ ├── HDTranslateModule_Example_cstring_output_translate.json
│ ├── HDTranslateModule_Example_ustring.txt
│ ├── HDTranslateModule_Example_ustring_output.json
│ ├── HDTranslateModule_Example_ustring_output_final.json
│ ├── HDTranslateModule_Example_ustring_output_translate.json
│ ├── find_chinese_cstrings.py
│ ├── find_chinese_ustrings.py
│ └── translate_strings.py
├── LICENSE
├── README.md
├── SwiftgemStringsOutput
└── Strings+Generated.swift
├── _Pods.xcodeproj
├── en.lproj
└── Localizable.strings
├── swiftgen.yml
└── temp.lproj
└── Localizable.strings
/.gitignore:
--------------------------------------------------------------------------------
1 | # macOS
2 | .DS_Store
3 |
4 | # Xcode
5 | build/
6 | *.pbxuser
7 | !default.pbxuser
8 | *.mode1v3
9 | !default.mode1v3
10 | *.mode2v3
11 | !default.mode2v3
12 | *.perspectivev3
13 | !default.perspectivev3
14 | xcuserdata/
15 | *.xccheckout
16 | *.moved-aside
17 | DerivedData
18 | *.hmap
19 | *.ipa
20 |
21 | # Bundler
22 | .bundle
23 |
24 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
25 | # Carthage/Checkouts
26 |
27 | Carthage/Build
28 |
29 | # We recommend against adding the Pods directory to your .gitignore. However
30 | # you should judge for yourself, the pros and cons are mentioned at:
31 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
32 | #
33 | # Note: if you ignore the Pods directory, make sure to uncomment
34 | # `pod install` in .travis.yml
35 | #
36 | # Pods/
37 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # references:
2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/
3 | # * https://github.com/supermarin/xcpretty#usage
4 |
5 | osx_image: xcode7.3
6 | language: objective-c
7 | # cache: cocoapods
8 | # podfile: Example/Podfile
9 | # before_install:
10 | # - gem install cocoapods # Since Travis is not always on latest version
11 | # - pod install --project-directory=Example
12 | script:
13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/HDTranslateModule.xcworkspace -scheme HDTranslateModule-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
14 | - pod lib lint
15 |
--------------------------------------------------------------------------------
/Assets/App国际化.xmind:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/Assets/App国际化.xmind
--------------------------------------------------------------------------------
/Assets/collect01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/Assets/collect01.jpg
--------------------------------------------------------------------------------
/Assets/collect02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/Assets/collect02.jpg
--------------------------------------------------------------------------------
/Assets/collect03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/Assets/collect03.jpg
--------------------------------------------------------------------------------
/Assets/collect04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/Assets/collect04.jpg
--------------------------------------------------------------------------------
/Assets/collect05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/Assets/collect05.jpg
--------------------------------------------------------------------------------
/Assets/effect.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/Assets/effect.gif
--------------------------------------------------------------------------------
/Assets/overall.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/Assets/overall.jpg
--------------------------------------------------------------------------------
/Example/HDTranslateModule.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule.xcodeproj/xcshareddata/xcschemes/HDTranslateModule-Example.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
66 |
72 |
73 |
74 |
75 |
76 |
77 |
83 |
85 |
91 |
92 |
93 |
94 |
96 |
97 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDAppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // HDAppDelegate.h
3 | // HDTranslateModule
4 | //
5 | // Created by denglibing on 06/19/2023.
6 | // Copyright (c) 2023 denglibing. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 |
11 | @interface HDAppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDAppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // HDAppDelegate.m
3 | // HDTranslateModule
4 | //
5 | // Created by denglibing on 06/19/2023.
6 | // Copyright (c) 2023 denglibing. All rights reserved.
7 | //
8 |
9 | #import "HDAppDelegate.h"
10 |
11 | #import
12 | #import
13 | #import
14 |
15 | @implementation HDAppDelegate
16 |
17 | - (void)logSystemLang {
18 | NSArray *languages = [NSLocale preferredLanguages];
19 | NSString *systemlanguage = [languages objectAtIndex:0];
20 | NSLog(@"systemlanguage: %@", systemlanguage);
21 | }
22 |
23 | - (void)reqPhotoAuthorization {
24 | PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
25 | if (status == PHAuthorizationStatusNotDetermined) {
26 |
27 | }
28 |
29 | [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
30 |
31 | }];
32 | }
33 |
34 | + (void)load {
35 | [JDLTTranslateModule openAutoTranslate];
36 | NSString *bundlePath = [NSBundle.mainBundle pathForResource:@"HDTranslateDemo" ofType:@"bundle"];
37 | NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
38 | [JDLTTranslateManager.shared customTranslateBundle:bundle tableName:@"HDTranslateModule"];
39 | [JDLTTranslateManager.shared updateLanguage:JDLTLanguageEN];
40 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
41 |
42 | });
43 | }
44 |
45 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
46 | {
47 | [self logSystemLang];
48 |
49 | // [JDLTTranslateModule openAutoTranslate];
50 | //
51 | // NSString *bundlePath = [NSBundle.mainBundle pathForResource:@"HDTranslateDemo" ofType:@"bundle"];
52 | // NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
53 | // [JDLTTranslateManager.shared customTranslateBundle:bundle tableName:@"HDTranslateModule"];
54 |
55 | // 测试info.plist
56 | [self reqPhotoAuthorization];
57 |
58 | return YES;
59 | }
60 |
61 | - (void)applicationWillResignActive:(UIApplication *)application
62 | {
63 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
64 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
65 | }
66 |
67 | - (void)applicationDidEnterBackground:(UIApplication *)application
68 | {
69 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
70 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
71 | }
72 |
73 | - (void)applicationWillEnterForeground:(UIApplication *)application
74 | {
75 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
76 | }
77 |
78 | - (void)applicationDidBecomeActive:(UIApplication *)application
79 | {
80 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
81 | }
82 |
83 | - (void)applicationWillTerminate:(UIApplication *)application
84 | {
85 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
86 | }
87 |
88 | @end
89 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDENViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // EXJDLTENViewController.h
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface HDENViewController : UIViewController
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDENViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // EXJDLTENViewController.m
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import "HDENViewController.h"
10 |
11 | @interface HDENViewController ()
12 |
13 | @end
14 |
15 | @implementation HDENViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do any additional setup after loading the view.
20 |
21 | }
22 |
23 | - (void)viewWillAppear:(BOOL)animated {
24 | [super viewWillAppear:animated];
25 |
26 | self.title = @"英文";
27 | }
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDExampleSwift.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HDExampleSwift.swift
3 | // HDFindStringDemo
4 | //
5 | // Created by denglibing on 2023/6/14.
6 | //
7 |
8 | import Foundation
9 | import UIKit
10 |
11 | @objc class HDExample: NSObject {
12 | private let value = "hello"
13 |
14 | @objc func log() {
15 | print("Swift 中")
16 | print("Swift En")
17 |
18 | print("是为 中")
19 |
20 | let label = UILabel()
21 | label.text = "Hello"
22 |
23 | let label2 = UILabel()
24 | label2.text = "你好"
25 |
26 | let label3 = UILabel()
27 | label3.text = "Hello 你好"
28 |
29 | debugPrint("L10n.Localizable.hello:\(L10n.Localizabless.hello)")
30 | debugPrint("L10n.Localizable.good:\(L10n.Localizabless.good)")
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDTranslateDemo.bundle/en.lproj/HDTranslateModule.strings:
--------------------------------------------------------------------------------
1 | "弹窗组件页面" = "Custom Popup window component page";
2 | "分类缓存是时间阀值:%d,当前缓存时间:%d" = "Custom Category cache is time threshold: %d, current cache time: %d";
3 | "更新资质合规:%@" = "Custom Update qualification compliance: %@";
4 | "第%d张图片不符合规范,请替换或删除后重新上传" = "Custom The %d image does not meet the specifications, please replace or delete it and upload it again";
5 | "订单编号:%@" = "Custom Order number: %@";
6 | "中文" = "Custom Chinese";
7 | "英文" = "Custom English";
8 | "hello" = "hello";
9 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDTranslateDemo.bundle/zh-Hans.lproj/HDTranslateModule.strings:
--------------------------------------------------------------------------------
1 | "弹窗组件页面" = "弹窗组件页面";
2 | "hello" = "你好";
3 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDTranslateModule-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | NSPhotoLibraryUsageDescription
28 | 需要访问您的相册,带您体验扫码、拍摄、扫红包、实景购物等
29 | UILaunchStoryboardName
30 | LaunchScreen
31 | UIMainStoryboardFile
32 | Main
33 | UIRequiredDeviceCapabilities
34 |
35 | armv7
36 |
37 | UISupportedInterfaceOrientations
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationLandscapeLeft
41 | UIInterfaceOrientationLandscapeRight
42 |
43 | UISupportedInterfaceOrientations~ipad
44 |
45 | UIInterfaceOrientationPortrait
46 | UIInterfaceOrientationPortraitUpsideDown
47 | UIInterfaceOrientationLandscapeLeft
48 | UIInterfaceOrientationLandscapeRight
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDTranslateModule-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_5_0
10 | #warning "This project uses features only available in iOS SDK 5.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | @import UIKit;
15 | @import Foundation;
16 | #endif
17 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDTranslateModule_Example-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/HDViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // HDViewController.h
3 | // HDTranslateModule
4 | //
5 | // Created by denglibing on 06/19/2023.
6 | // Copyright (c) 2023 denglibing. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 |
11 | @interface HDViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/UIButtonCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIButtonCell.h
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface UIButtonCell : UITableViewCell
14 |
15 | @property (nonatomic, strong) UIButton *button;
16 |
17 | @end
18 |
19 |
20 | @interface UIButtonCell2 : UIButtonCell
21 |
22 | @end
23 |
24 | NS_ASSUME_NONNULL_END
25 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/UIButtonCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIButtonCell.m
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import "UIButtonCell.h"
10 |
11 | @implementation UIButtonCell
12 |
13 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
14 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
15 | if (self) {
16 | _button = [UIButton buttonWithType:UIButtonTypeCustom];
17 | _button.frame = self.contentView.bounds;
18 | [_button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
19 | _button.titleLabel.numberOfLines = 0;
20 | _button.titleLabel.font = [UIFont systemFontOfSize:14];
21 | [self.contentView addSubview:_button];
22 | }
23 | return self;
24 | }
25 |
26 | - (void)layoutSubviews {
27 | [super layoutSubviews];
28 |
29 | _button.frame = self.contentView.bounds;
30 | }
31 |
32 | - (void)awakeFromNib {
33 | [super awakeFromNib];
34 | // Initialization code
35 | }
36 |
37 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
38 | [super setSelected:selected animated:animated];
39 |
40 | // Configure the view for the selected state
41 | }
42 |
43 | @end
44 |
45 |
46 |
47 | @implementation UIButtonCell2
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/UILabelCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // UILabelCell.h
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/18.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface UILabelCell : UITableViewCell
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/UILabelCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // UILabelCell.m
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/18.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import "UILabelCell.h"
10 |
11 | @implementation UILabelCell
12 |
13 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
14 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
15 | if (self) {
16 | self.textLabel.numberOfLines = 0;
17 | self.textLabel.font = [UIFont systemFontOfSize:14];
18 | }
19 | return self;
20 | }
21 |
22 | - (void)awakeFromNib {
23 | [super awakeFromNib];
24 | // Initialization code
25 | }
26 |
27 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
28 | [super setSelected:selected animated:animated];
29 |
30 | // Configure the view for the selected state
31 | }
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/UITextFieldCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // UITextFieldCell.h
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface UITextFieldCell : UITableViewCell
14 |
15 | @property (nonatomic, strong) UITextField *textField;
16 |
17 | @end
18 |
19 | @interface UITextFieldCell2 : UITextFieldCell
20 | @end
21 |
22 | NS_ASSUME_NONNULL_END
23 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/UITextFieldCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // UITextFieldCell.m
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import "UITextFieldCell.h"
10 |
11 | @implementation UITextFieldCell
12 |
13 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
14 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
15 | if (self) {
16 | _textField = [[UITextField alloc] init];
17 | _textField.font = [UIFont systemFontOfSize:14];
18 | [self.contentView addSubview:_textField];
19 | }
20 | return self;
21 | }
22 |
23 | - (void)layoutSubviews {
24 | [super layoutSubviews];
25 |
26 | _textField.frame = CGRectMake(10, 5, self.contentView.bounds.size.width - 20, self.contentView.bounds.size.height - 10);
27 | }
28 |
29 | @end
30 |
31 |
32 |
33 | @implementation UITextFieldCell2
34 | @end
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/UITextViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // UITextViewCell.h
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface UITextViewCell : UITableViewCell
14 |
15 | @property (nonatomic, strong) UITextView *textView;
16 |
17 | @end
18 |
19 | @interface UITextViewCell2 : UITextViewCell
20 |
21 | @end
22 |
23 | NS_ASSUME_NONNULL_END
24 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/UITextViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // UITextViewCell.m
3 | // JDLTTranslateModule_Example
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | // Copyright © 2023 邓立兵. All rights reserved.
7 | //
8 |
9 | #import "UITextViewCell.h"
10 |
11 | @implementation UITextViewCell
12 |
13 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
14 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
15 | if (self) {
16 | _textView = [[UITextView alloc] init];
17 | _textView.font = [UIFont systemFontOfSize:14];
18 | _textView.editable = NO;
19 | [self.contentView addSubview:_textView];
20 | }
21 | return self;
22 | }
23 |
24 | - (void)layoutSubviews {
25 | [super layoutSubviews];
26 |
27 | _textView.frame = CGRectMake(10, 5, self.contentView.bounds.size.width - 20, self.contentView.bounds.size.height - 10);
28 | }
29 |
30 | @end
31 |
32 |
33 | @implementation UITextViewCell2
34 | @end
35 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 | CFBundleDisplayName="HDTranslate";
4 |
5 | NSPhotoLibraryUsageDescription="Needs access to your camera to take you to experience code scanning, shooting, red envelope scanning, reality shopping, etc";
6 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/en.lproj/LaunchScreen.strings:
--------------------------------------------------------------------------------
1 | "Ev1-cz-gJn.text" = "I am English LaunchScreen";
2 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/en.lproj/Localizabless.strings:
--------------------------------------------------------------------------------
1 | /*
2 | Localizable.strings
3 | HDTranslateModule
4 |
5 | Created by denglibing on 2023/8/16.
6 | Copyright © 2023 denglibing5. All rights reserved.
7 | */
8 |
9 | "hello" = "hello";
10 | "good" = "good";
11 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // HDTranslateModule
4 | //
5 | // Created by denglibing on 06/19/2023.
6 | // Copyright (c) 2023 denglibing. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 | #import "HDAppDelegate.h"
11 |
12 | int main(int argc, char * argv[])
13 | {
14 | @autoreleasepool {
15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([HDAppDelegate class]));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/zh-Hans.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 | CFBundleDisplayName="HD多语言";
4 |
5 | NSPhotoLibraryUsageDescription="需要访问您的相册,带您体验扫码、拍摄、扫红包、实景购物等";
6 |
7 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/zh-Hans.lproj/LaunchScreen.strings:
--------------------------------------------------------------------------------
1 | "Ev1-cz-gJn.text" = "我是中文启动图";
2 |
--------------------------------------------------------------------------------
/Example/HDTranslateModule/zh-Hans.lproj/Localizabless.strings:
--------------------------------------------------------------------------------
1 | /*
2 | Localizable.strings
3 | HDTranslateModule
4 |
5 | Created by denglibing on 2023/8/16.
6 | Copyright © 2023 denglibing5. All rights reserved.
7 | */
8 |
9 | "hello" = "你好";
10 | "good" = "很棒";
11 |
--------------------------------------------------------------------------------
/Example/Podfile:
--------------------------------------------------------------------------------
1 | use_frameworks!
2 |
3 | platform :ios, '10.0'
4 |
5 | target 'HDTranslateModule_Example' do
6 | pod 'HDTranslateModule', :path => '../'
7 | pod 'SwiftGen', '~> 6.0'
8 |
9 | target 'HDTranslateModule_Tests' do
10 | inherit! :search_paths
11 |
12 |
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/Example/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - HDTranslateModule (0.1.0)
3 | - SwiftGen (6.6.2)
4 |
5 | DEPENDENCIES:
6 | - HDTranslateModule (from `../`)
7 | - SwiftGen (~> 6.0)
8 |
9 | SPEC REPOS:
10 | trunk:
11 | - SwiftGen
12 |
13 | EXTERNAL SOURCES:
14 | HDTranslateModule:
15 | :path: "../"
16 |
17 | SPEC CHECKSUMS:
18 | HDTranslateModule: f78847bc1fe1805e3edba5abcbf2ec051eb83e69
19 | SwiftGen: 1366a7f71aeef49954ca5a63ba4bef6b0f24138c
20 |
21 | PODFILE CHECKSUM: 1754188ee48cc9b8d6c53ac0b7b6a3d3697da986
22 |
23 | COCOAPODS: 1.11.3
24 |
--------------------------------------------------------------------------------
/Example/Pods/Local Podspecs/HDTranslateModule.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "HDTranslateModule",
3 | "version": "0.1.0",
4 | "summary": "iOS多语言解决方案大全:半自动化+特殊场景手动解决项目中的多语言问题",
5 | "description": "TODO: Add long description of the pod here.",
6 | "homepage": "https://github.com/erduoniba/HDTranslateModule",
7 | "license": {
8 | "type": "MIT",
9 | "file": "LICENSE"
10 | },
11 | "authors": {
12 | "denglibing": "328418417@qq.com"
13 | },
14 | "source": {
15 | "git": "git@github.com:erduoniba/HDTranslateModule.git",
16 | "tag": "0.1.0"
17 | },
18 | "platforms": {
19 | "ios": "10.0"
20 | },
21 | "source_files": "HDTranslateModule/Classes/**/*.{h,m,py}",
22 | "public_header_files": "HDTranslateModule/Classes**/*.h",
23 | "resources": "HDTranslateModule/Assets/*"
24 | }
25 |
--------------------------------------------------------------------------------
/Example/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - HDTranslateModule (0.1.0)
3 | - SwiftGen (6.6.2)
4 |
5 | DEPENDENCIES:
6 | - HDTranslateModule (from `../`)
7 | - SwiftGen (~> 6.0)
8 |
9 | SPEC REPOS:
10 | trunk:
11 | - SwiftGen
12 |
13 | EXTERNAL SOURCES:
14 | HDTranslateModule:
15 | :path: "../"
16 |
17 | SPEC CHECKSUMS:
18 | HDTranslateModule: f78847bc1fe1805e3edba5abcbf2ec051eb83e69
19 | SwiftGen: 1366a7f71aeef49954ca5a63ba4bef6b0f24138c
20 |
21 | PODFILE CHECKSUM: 1754188ee48cc9b8d6c53ac0b7b6a3d3697da986
22 |
23 | COCOAPODS: 1.11.3
24 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/LICENCE:
--------------------------------------------------------------------------------
1 | MIT Licence
2 |
3 | Copyright (c) 2022 SwiftGen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildMachineOSBuild
6 | 21F79
7 | CFBundleDevelopmentRegion
8 | en
9 | CFBundleExecutable
10 | SwiftGen_SwiftGenCLI
11 | CFBundleIdentifier
12 | SwiftGen.SwiftGenCLI.resources
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | SwiftGen_SwiftGenCLI
17 | CFBundlePackageType
18 | BNDL
19 | CFBundleSupportedPlatforms
20 |
21 | MacOSX
22 |
23 | DTCompiler
24 | com.apple.compilers.llvm.clang.1_0
25 | DTPlatformBuild
26 | 13F100
27 | DTPlatformName
28 | macosx
29 | DTPlatformVersion
30 | 12.3
31 | DTSDKBuild
32 | 21E226
33 | DTSDKName
34 | macosx12.3
35 | DTXcode
36 | 1341
37 | DTXcodeBuild
38 | 13F100
39 | LSMinimumSystemVersion
40 | 10.11
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/colors/literals-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if palettes %}
5 | {% set enumName %}{{param.enumName|default:"ColorName"}}{% endset %}
6 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
7 | #if os(macOS)
8 | import AppKit
9 | {% if enumName != 'NSColor' %}
10 | {{accessModifier}} enum {{enumName}} { }
11 | {% endif %}
12 | #elseif os(iOS) || os(tvOS) || os(watchOS)
13 | import UIKit
14 | {% if enumName != 'UIColor' %}
15 | {{accessModifier}} enum {{enumName}} { }
16 | {% endif %}
17 | #endif
18 |
19 | // swiftlint:disable superfluous_disable_command
20 | // swiftlint:disable file_length
21 |
22 | // MARK: - Colors
23 |
24 | // swiftlint:disable identifier_name line_length type_body_length
25 | {{accessModifier}} extension {{enumName}} {
26 | {% macro h2f hex %}{{hex|hexToInt|int255toFloat}}{% endmacro %}
27 | {% macro enumBlock colors accessPrefix %}
28 | {% for color in colors %}
29 | /// 0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}} (r: {{color.red|hexToInt}}, g: {{color.green|hexToInt}}, b: {{color.blue|hexToInt}}, a: {{color.alpha|hexToInt}})
30 | {{accessPrefix}}static let {{color.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = #colorLiteral(red: {%+ call h2f color.red %}, green: {%+ call h2f color.green %}, blue: {%+ call h2f color.blue %}, alpha: {%+ call h2f color.alpha %})
31 | {% endfor %}
32 | {% endmacro %}
33 | {% if palettes.count > 1 or param.forceFileNameEnum %}
34 | {% set accessPrefix %}{{accessModifier}} {%+ endset %}
35 | {% for palette in palettes %}
36 | enum {{palette.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
37 | {% filter indent:2," ",true %}{% call enumBlock palette.colors accessPrefix %}{% endfilter %}
38 | }
39 | {% endfor %}
40 | {% else %}
41 | {% call enumBlock palettes.first.colors "" %}
42 | {% endif %}
43 | }
44 | // swiftlint:enable identifier_name line_length type_body_length
45 | {% else %}
46 | // No color found
47 | {% endif %}
48 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/colors/literals-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if palettes %}
5 | {% set enumName %}{{param.enumName|default:"ColorName"}}{% endset %}
6 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
7 | #if os(macOS)
8 | import AppKit
9 | {% if enumName != 'NSColor' %}
10 | {{accessModifier}} enum {{enumName}} { }
11 | {% endif %}
12 | #elseif os(iOS) || os(tvOS) || os(watchOS)
13 | import UIKit
14 | {% if enumName != 'UIColor' %}
15 | {{accessModifier}} enum {{enumName}} { }
16 | {% endif %}
17 | #endif
18 |
19 | // swiftlint:disable superfluous_disable_command
20 | // swiftlint:disable file_length
21 |
22 | // MARK: - Colors
23 |
24 | // swiftlint:disable identifier_name line_length type_body_length
25 | {{accessModifier}} extension {{enumName}} {
26 | {% macro h2f hex %}{{hex|hexToInt|int255toFloat}}{% endmacro %}
27 | {% macro enumBlock colors accessPrefix %}
28 | {% for color in colors %}
29 | /// 0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}} (r: {{color.red|hexToInt}}, g: {{color.green|hexToInt}}, b: {{color.blue|hexToInt}}, a: {{color.alpha|hexToInt}})
30 | {{accessPrefix}}static let {{color.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = #colorLiteral(red: {%+ call h2f color.red %}, green: {%+ call h2f color.green %}, blue: {%+ call h2f color.blue %}, alpha: {%+ call h2f color.alpha %})
31 | {% endfor %}
32 | {% endmacro %}
33 | {% if palettes.count > 1 or param.forceFileNameEnum %}
34 | {% set accessPrefix %}{{accessModifier}} {%+ endset %}
35 | {% for palette in palettes %}
36 | enum {{palette.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
37 | {% filter indent:2," ",true %}{% call enumBlock palette.colors accessPrefix %}{% endfilter %}
38 | }
39 | {% endfor %}
40 | {% else %}
41 | {% call enumBlock palettes.first.colors "" %}
42 | {% endif %}
43 | }
44 | // swiftlint:enable identifier_name line_length type_body_length
45 | {% else %}
46 | // No color found
47 | {% endif %}
48 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/colors/swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if palettes %}
5 | {% set colorAlias %}{{param.colorAliasName|default:"Color"}}{% endset %}
6 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
7 | #if os(macOS)
8 | import AppKit.NSColor
9 | {{accessModifier}} typealias {{colorAlias}} = NSColor
10 | #elseif os(iOS) || os(tvOS) || os(watchOS)
11 | import UIKit.UIColor
12 | {{accessModifier}} typealias {{colorAlias}} = UIColor
13 | #endif
14 |
15 | // swiftlint:disable superfluous_disable_command file_length implicit_return
16 |
17 | // MARK: - Colors
18 |
19 | // swiftlint:disable identifier_name line_length type_body_length
20 | {% set enumName %}{{param.enumName|default:"ColorName"}}{% endset %}
21 | {{accessModifier}} struct {{enumName}} {
22 | {{accessModifier}} let rgbaValue: UInt32
23 | {{accessModifier}} var color: {{colorAlias}} { return {{colorAlias}}(named: self) }
24 |
25 | {% macro rgbaValue color %}0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}}{% endmacro %}
26 | {% macro enumBlock colors %}
27 | {% for color in colors %}
28 | ///
29 | /// Alpha: {{color.alpha|hexToInt|int255toFloat|percent}}
(0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}})
30 | {{accessModifier}} static let {{color.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{enumName}}(rgbaValue: {%+ call rgbaValue color %})
31 | {% endfor %}
32 | {% endmacro %}
33 | {% if palettes.count > 1 or param.forceFileNameEnum %}
34 | {% for palette in palettes %}
35 | {{accessModifier}} enum {{palette.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
36 | {% filter indent:2," ",true %}{% call enumBlock palette.colors %}{% endfilter %}
37 | }
38 | {% endfor %}
39 | {% else %}
40 | {% call enumBlock palettes.first.colors %}
41 | {% endif %}
42 | }
43 | // swiftlint:enable identifier_name line_length type_body_length
44 |
45 | // MARK: - Implementation Details
46 |
47 | internal extension {{colorAlias}} {
48 | convenience init(rgbaValue: UInt32) {
49 | let components = RGBAComponents(rgbaValue: rgbaValue).normalized
50 | self.init(red: components[0], green: components[1], blue: components[2], alpha: components[3])
51 | }
52 | }
53 |
54 | private struct RGBAComponents {
55 | let rgbaValue: UInt32
56 |
57 | private var shifts: [UInt32] {
58 | [
59 | rgbaValue >> 24, // red
60 | rgbaValue >> 16, // green
61 | rgbaValue >> 8, // blue
62 | rgbaValue // alpha
63 | ]
64 | }
65 |
66 | private var components: [CGFloat] {
67 | shifts.map { CGFloat($0 & 0xff) }
68 | }
69 |
70 | var normalized: [CGFloat] {
71 | components.map { $0 / 255.0 }
72 | }
73 | }
74 |
75 | {{accessModifier}} extension {{colorAlias}} {
76 | convenience init(named color: {{enumName}}) {
77 | self.init(rgbaValue: color.rgbaValue)
78 | }
79 | }
80 | {% else %}
81 | // No color found
82 | {% endif %}
83 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/colors/swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if palettes %}
5 | {% set colorAlias %}{{param.colorAliasName|default:"Color"}}{% endset %}
6 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
7 | #if os(macOS)
8 | import AppKit.NSColor
9 | {{accessModifier}} typealias {{colorAlias}} = NSColor
10 | #elseif os(iOS) || os(tvOS) || os(watchOS)
11 | import UIKit.UIColor
12 | {{accessModifier}} typealias {{colorAlias}} = UIColor
13 | #endif
14 |
15 | // swiftlint:disable superfluous_disable_command file_length implicit_return
16 |
17 | // MARK: - Colors
18 |
19 | // swiftlint:disable identifier_name line_length type_body_length
20 | {% set enumName %}{{param.enumName|default:"ColorName"}}{% endset %}
21 | {{accessModifier}} struct {{enumName}} {
22 | {{accessModifier}} let rgbaValue: UInt32
23 | {{accessModifier}} var color: {{colorAlias}} { return {{colorAlias}}(named: self) }
24 |
25 | {% macro rgbaValue color %}0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}}{% endmacro %}
26 | {% macro enumBlock colors %}
27 | {% for color in colors %}
28 | ///
29 | /// Alpha: {{color.alpha|hexToInt|int255toFloat|percent}}
(0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}})
30 | {{accessModifier}} static let {{color.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{enumName}}(rgbaValue: {%+ call rgbaValue color %})
31 | {% endfor %}
32 | {% endmacro %}
33 | {% if palettes.count > 1 or param.forceFileNameEnum %}
34 | {% for palette in palettes %}
35 | {{accessModifier}} enum {{palette.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
36 | {% filter indent:2," ",true %}{% call enumBlock palette.colors %}{% endfilter %}
37 | }
38 | {% endfor %}
39 | {% else %}
40 | {% call enumBlock palettes.first.colors %}
41 | {% endif %}
42 | }
43 | // swiftlint:enable identifier_name line_length type_body_length
44 |
45 | // MARK: - Implementation Details
46 |
47 | internal extension {{colorAlias}} {
48 | convenience init(rgbaValue: UInt32) {
49 | let components = RGBAComponents(rgbaValue: rgbaValue).normalized
50 | self.init(red: components[0], green: components[1], blue: components[2], alpha: components[3])
51 | }
52 | }
53 |
54 | private struct RGBAComponents {
55 | let rgbaValue: UInt32
56 |
57 | private var shifts: [UInt32] {
58 | [
59 | rgbaValue >> 24, // red
60 | rgbaValue >> 16, // green
61 | rgbaValue >> 8, // blue
62 | rgbaValue // alpha
63 | ]
64 | }
65 |
66 | private var components: [CGFloat] {
67 | shifts.map { CGFloat($0 & 0xff) }
68 | }
69 |
70 | var normalized: [CGFloat] {
71 | components.map { $0 / 255.0 }
72 | }
73 | }
74 |
75 | {{accessModifier}} extension {{colorAlias}} {
76 | convenience init(named color: {{enumName}}) {
77 | self.init(rgbaValue: color.rgbaValue)
78 | }
79 | }
80 | {% else %}
81 | // No color found
82 | {% endif %}
83 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/files/flat-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if groups.count > 0 %}
5 | {% set enumName %}{{param.enumName|default:"Files"}}{% endset %}
6 | {% set useExt %}{% if param.useExtension|default:"true" %}true{% endif %}{% endset %}
7 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
8 | {% set resourceType %}{{param.resourceTypeName|default:"File"}}{% endset %}
9 | import Foundation
10 |
11 | // swiftlint:disable superfluous_disable_command file_length line_length implicit_return
12 |
13 | // MARK: - Files
14 |
15 | {% macro groupBlock group %}
16 | {% for file in group.files %}
17 | {% call fileBlock file %}
18 | {% endfor %}
19 | {% for dir in group.directories %}
20 | {% call dirBlock dir %}
21 | {% endfor %}
22 | {% endmacro %}
23 | {% macro fileBlock file %}
24 | /// {%+ if file.path and param.preservePath %}{{file.path}}/{% endif %}{{file.name}}{% if file.ext %}.{{file.ext}}{% endif +%}
25 | {% set identifier %}{{ file.name }}{% if useExt %}.{{ file.ext }}{% endif %}{% endset %}
26 | {{accessModifier}} static let {{identifier|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{resourceType}}(name: "{{file.name}}", ext: {%+ if file.ext %}"{{file.ext}}"{% else %}nil{% endif %}, relativePath: "{{file.path if param.preservePath}}", mimeType: "{{file.mimeType}}")
27 | {% endmacro %}
28 | {% macro dirBlock directory %}
29 | {% for file in directory.files %}
30 | {% call fileBlock file %}
31 | {% endfor %}
32 | {% for dir in directory.directories %}
33 | {% call dirBlock dir %}
34 | {% endfor %}
35 | {% endmacro %}
36 | // swiftlint:disable explicit_type_interface identifier_name
37 | // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
38 | {{accessModifier}} enum {{enumName}} {
39 | {% if groups.count > 1 or param.forceFileNameEnum %}
40 | {% for group in groups %}
41 | {{accessModifier}} enum {{group.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
42 | {% filter indent:2 %}{% call groupBlock group %}{% endfilter %}
43 | }
44 | {% endfor %}
45 | {% else %}
46 | {% call groupBlock groups.first %}
47 | {% endif %}
48 | }
49 | // swiftlint:enable explicit_type_interface identifier_name
50 | // swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
51 |
52 | // MARK: - Implementation Details
53 |
54 | {{accessModifier}} struct {{resourceType}} {
55 | {{accessModifier}} let name: String
56 | {{accessModifier}} let ext: String?
57 | {{accessModifier}} let relativePath: String
58 | {{accessModifier}} let mimeType: String
59 |
60 | {{accessModifier}} var url: URL {
61 | return url(locale: nil)
62 | }
63 |
64 | {{accessModifier}} func url(locale: Locale?) -> URL {
65 | let bundle = {{param.bundle|default:"BundleToken.bundle"}}
66 | let url = bundle.url(
67 | forResource: name,
68 | withExtension: ext,
69 | subdirectory: relativePath,
70 | localization: locale?.identifier
71 | )
72 | guard let result = url else {
73 | let file = name + (ext.flatMap { ".\($0)" } ?? "")
74 | fatalError("Could not locate file named \(file)")
75 | }
76 | return result
77 | }
78 |
79 | {{accessModifier}} var path: String {
80 | return path(locale: nil)
81 | }
82 |
83 | {{accessModifier}} func path(locale: Locale?) -> String {
84 | return url(locale: locale).path
85 | }
86 | }
87 | {% if not param.bundle %}
88 |
89 | // swiftlint:disable convenience_type explicit_type_interface
90 | private final class BundleToken {
91 | static let bundle: Bundle = {
92 | #if SWIFT_PACKAGE
93 | return Bundle.module
94 | #else
95 | return Bundle(for: BundleToken.self)
96 | #endif
97 | }()
98 | }
99 | // swiftlint:enable convenience_type explicit_type_interface
100 | {% endif %}
101 | {% else %}
102 | // No files found
103 | {% endif %}
104 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/files/flat-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if groups.count > 0 %}
5 | {% set enumName %}{{param.enumName|default:"Files"}}{% endset %}
6 | {% set useExt %}{% if param.useExtension|default:"true" %}true{% endif %}{% endset %}
7 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
8 | {% set resourceType %}{{param.resourceTypeName|default:"File"}}{% endset %}
9 | import Foundation
10 |
11 | // swiftlint:disable superfluous_disable_command file_length line_length implicit_return
12 |
13 | // MARK: - Files
14 |
15 | {% macro groupBlock group %}
16 | {% for file in group.files %}
17 | {% call fileBlock file %}
18 | {% endfor %}
19 | {% for dir in group.directories %}
20 | {% call dirBlock dir %}
21 | {% endfor %}
22 | {% endmacro %}
23 | {% macro fileBlock file %}
24 | /// {%+ if file.path and param.preservePath %}{{file.path}}/{% endif %}{{file.name}}{% if file.ext %}.{{file.ext}}{% endif +%}
25 | {% set identifier %}{{ file.name }}{% if useExt %}.{{ file.ext }}{% endif %}{% endset %}
26 | {{accessModifier}} static let {{identifier|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{resourceType}}(name: "{{file.name}}", ext: {%+ if file.ext %}"{{file.ext}}"{% else %}nil{% endif %}, relativePath: "{{file.path if param.preservePath}}", mimeType: "{{file.mimeType}}")
27 | {% endmacro %}
28 | {% macro dirBlock directory %}
29 | {% for file in directory.files %}
30 | {% call fileBlock file %}
31 | {% endfor %}
32 | {% for dir in directory.directories %}
33 | {% call dirBlock dir %}
34 | {% endfor %}
35 | {% endmacro %}
36 | // swiftlint:disable explicit_type_interface identifier_name
37 | // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
38 | {{accessModifier}} enum {{enumName}} {
39 | {% if groups.count > 1 or param.forceFileNameEnum %}
40 | {% for group in groups %}
41 | {{accessModifier}} enum {{group.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
42 | {% filter indent:2 %}{% call groupBlock group %}{% endfilter %}
43 | }
44 | {% endfor %}
45 | {% else %}
46 | {% call groupBlock groups.first %}
47 | {% endif %}
48 | }
49 | // swiftlint:enable explicit_type_interface identifier_name
50 | // swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
51 |
52 | // MARK: - Implementation Details
53 |
54 | {{accessModifier}} struct {{resourceType}} {
55 | {{accessModifier}} let name: String
56 | {{accessModifier}} let ext: String?
57 | {{accessModifier}} let relativePath: String
58 | {{accessModifier}} let mimeType: String
59 |
60 | {{accessModifier}} var url: URL {
61 | return url(locale: nil)
62 | }
63 |
64 | {{accessModifier}} func url(locale: Locale?) -> URL {
65 | let bundle = {{param.bundle|default:"BundleToken.bundle"}}
66 | let url = bundle.url(
67 | forResource: name,
68 | withExtension: ext,
69 | subdirectory: relativePath,
70 | localization: locale?.identifier
71 | )
72 | guard let result = url else {
73 | let file = name + (ext.flatMap { ".\($0)" } ?? "")
74 | fatalError("Could not locate file named \(file)")
75 | }
76 | return result
77 | }
78 |
79 | {{accessModifier}} var path: String {
80 | return path(locale: nil)
81 | }
82 |
83 | {{accessModifier}} func path(locale: Locale?) -> String {
84 | return url(locale: locale).path
85 | }
86 | }
87 | {% if not param.bundle %}
88 |
89 | // swiftlint:disable convenience_type explicit_type_interface
90 | private final class BundleToken {
91 | static let bundle: Bundle = {
92 | #if SWIFT_PACKAGE
93 | return Bundle.module
94 | #else
95 | return Bundle(for: BundleToken.self)
96 | #endif
97 | }()
98 | }
99 | // swiftlint:enable convenience_type explicit_type_interface
100 | {% endif %}
101 | {% else %}
102 | // No files found
103 | {% endif %}
104 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/files/structured-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if groups.count > 0 %}
5 | {% set enumName %}{{param.enumName|default:"Files"}}{% endset %}
6 | {% set useExt %}{% if param.useExtension|default:"true" %}true{% endif %}{% endset %}
7 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
8 | {% set resourceType %}{{param.resourceTypeName|default:"File"}}{% endset %}
9 | import Foundation
10 |
11 | // swiftlint:disable superfluous_disable_command file_length line_length implicit_return
12 |
13 | // MARK: - Files
14 |
15 | {% macro groupBlock group %}
16 | {% for file in group.files %}
17 | {% call fileBlock file %}
18 | {% endfor %}
19 | {% for dir in group.directories %}
20 | {% call dirBlock dir "" %}
21 | {% endfor %}
22 | {% endmacro %}
23 | {% macro fileBlock file %}
24 | /// {%+ if file.path and param.preservePath %}{{file.path}}/{% endif %}{{file.name}}{% if file.ext %}.{{file.ext}}{% endif +%}
25 | {% set identifier %}{{ file.name }}{% if useExt %}.{{ file.ext }}{% endif %}{% endset %}
26 | {{accessModifier}} static let {{identifier|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{resourceType}}(name: "{{file.name}}", ext: {%+ if file.ext %}"{{file.ext}}"{% else %}nil{% endif %}, relativePath: "{{file.path if param.preservePath}}", mimeType: "{{file.mimeType}}")
27 | {% endmacro %}
28 | {% macro dirBlock directory parent %}
29 | {% set fullDir %}{{parent}}{{directory.name}}/{% endset %}
30 | /// {{ fullDir }}
31 | {{accessModifier}} enum {{directory.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
32 | {% for file in directory.files %}
33 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
34 | {% endfor %}
35 | {% for dir in directory.directories %}
36 | {% filter indent:2," ",true %}{% call dirBlock dir fullDir %}{% endfilter %}
37 | {% endfor %}
38 | }
39 | {% endmacro %}
40 | // swiftlint:disable explicit_type_interface identifier_name
41 | // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
42 | {{accessModifier}} enum {{enumName}} {
43 | {% if groups.count > 1 or param.forceFileNameEnum %}
44 | {% for group in groups %}
45 | {{accessModifier}} enum {{group.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
46 | {% filter indent:2," ",true %}{% call groupBlock group %}{% endfilter %}
47 | }
48 | {% endfor %}
49 | {% else %}
50 | {% call groupBlock groups.first %}
51 | {% endif %}
52 | }
53 | // swiftlint:enable explicit_type_interface identifier_name
54 | // swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
55 |
56 | // MARK: - Implementation Details
57 |
58 | {{accessModifier}} struct {{resourceType}} {
59 | {{accessModifier}} let name: String
60 | {{accessModifier}} let ext: String?
61 | {{accessModifier}} let relativePath: String
62 | {{accessModifier}} let mimeType: String
63 |
64 | {{accessModifier}} var url: URL {
65 | return url(locale: nil)
66 | }
67 |
68 | {{accessModifier}} func url(locale: Locale?) -> URL {
69 | let bundle = {{param.bundle|default:"BundleToken.bundle"}}
70 | let url = bundle.url(
71 | forResource: name,
72 | withExtension: ext,
73 | subdirectory: relativePath,
74 | localization: locale?.identifier
75 | )
76 | guard let result = url else {
77 | let file = name + (ext.flatMap { ".\($0)" } ?? "")
78 | fatalError("Could not locate file named \(file)")
79 | }
80 | return result
81 | }
82 |
83 | {{accessModifier}} var path: String {
84 | return path(locale: nil)
85 | }
86 |
87 | {{accessModifier}} func path(locale: Locale?) -> String {
88 | return url(locale: locale).path
89 | }
90 | }
91 | {% if not param.bundle %}
92 |
93 | // swiftlint:disable convenience_type explicit_type_interface
94 | private final class BundleToken {
95 | static let bundle: Bundle = {
96 | #if SWIFT_PACKAGE
97 | return Bundle.module
98 | #else
99 | return Bundle(for: BundleToken.self)
100 | #endif
101 | }()
102 | }
103 | // swiftlint:enable convenience_type explicit_type_interface
104 | {% endif %}
105 | {% else %}
106 | // No files found
107 | {% endif %}
108 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/files/structured-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if groups.count > 0 %}
5 | {% set enumName %}{{param.enumName|default:"Files"}}{% endset %}
6 | {% set useExt %}{% if param.useExtension|default:"true" %}true{% endif %}{% endset %}
7 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
8 | {% set resourceType %}{{param.resourceTypeName|default:"File"}}{% endset %}
9 | import Foundation
10 |
11 | // swiftlint:disable superfluous_disable_command file_length line_length implicit_return
12 |
13 | // MARK: - Files
14 |
15 | {% macro groupBlock group %}
16 | {% for file in group.files %}
17 | {% call fileBlock file %}
18 | {% endfor %}
19 | {% for dir in group.directories %}
20 | {% call dirBlock dir "" %}
21 | {% endfor %}
22 | {% endmacro %}
23 | {% macro fileBlock file %}
24 | /// {%+ if file.path and param.preservePath %}{{file.path}}/{% endif %}{{file.name}}{% if file.ext %}.{{file.ext}}{% endif +%}
25 | {% set identifier %}{{ file.name }}{% if useExt %}.{{ file.ext }}{% endif %}{% endset %}
26 | {{accessModifier}} static let {{identifier|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{resourceType}}(name: "{{file.name}}", ext: {%+ if file.ext %}"{{file.ext}}"{% else %}nil{% endif %}, relativePath: "{{file.path if param.preservePath}}", mimeType: "{{file.mimeType}}")
27 | {% endmacro %}
28 | {% macro dirBlock directory parent %}
29 | {% set fullDir %}{{parent}}{{directory.name}}/{% endset %}
30 | /// {{ fullDir }}
31 | {{accessModifier}} enum {{directory.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
32 | {% for file in directory.files %}
33 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
34 | {% endfor %}
35 | {% for dir in directory.directories %}
36 | {% filter indent:2," ",true %}{% call dirBlock dir fullDir %}{% endfilter %}
37 | {% endfor %}
38 | }
39 | {% endmacro %}
40 | // swiftlint:disable explicit_type_interface identifier_name
41 | // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
42 | {{accessModifier}} enum {{enumName}} {
43 | {% if groups.count > 1 or param.forceFileNameEnum %}
44 | {% for group in groups %}
45 | {{accessModifier}} enum {{group.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
46 | {% filter indent:2," ",true %}{% call groupBlock group %}{% endfilter %}
47 | }
48 | {% endfor %}
49 | {% else %}
50 | {% call groupBlock groups.first %}
51 | {% endif %}
52 | }
53 | // swiftlint:enable explicit_type_interface identifier_name
54 | // swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
55 |
56 | // MARK: - Implementation Details
57 |
58 | {{accessModifier}} struct {{resourceType}} {
59 | {{accessModifier}} let name: String
60 | {{accessModifier}} let ext: String?
61 | {{accessModifier}} let relativePath: String
62 | {{accessModifier}} let mimeType: String
63 |
64 | {{accessModifier}} var url: URL {
65 | return url(locale: nil)
66 | }
67 |
68 | {{accessModifier}} func url(locale: Locale?) -> URL {
69 | let bundle = {{param.bundle|default:"BundleToken.bundle"}}
70 | let url = bundle.url(
71 | forResource: name,
72 | withExtension: ext,
73 | subdirectory: relativePath,
74 | localization: locale?.identifier
75 | )
76 | guard let result = url else {
77 | let file = name + (ext.flatMap { ".\($0)" } ?? "")
78 | fatalError("Could not locate file named \(file)")
79 | }
80 | return result
81 | }
82 |
83 | {{accessModifier}} var path: String {
84 | return path(locale: nil)
85 | }
86 |
87 | {{accessModifier}} func path(locale: Locale?) -> String {
88 | return url(locale: locale).path
89 | }
90 | }
91 | {% if not param.bundle %}
92 |
93 | // swiftlint:disable convenience_type explicit_type_interface
94 | private final class BundleToken {
95 | static let bundle: Bundle = {
96 | #if SWIFT_PACKAGE
97 | return Bundle.module
98 | #else
99 | return Bundle(for: BundleToken.self)
100 | #endif
101 | }()
102 | }
103 | // swiftlint:enable convenience_type explicit_type_interface
104 | {% endif %}
105 | {% else %}
106 | // No files found
107 | {% endif %}
108 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/fonts/swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if families %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | {% set fontType %}{{param.fontTypeName|default:"FontConvertible"}}{% endset %}
7 | #if os(macOS)
8 | import AppKit.NSFont
9 | #elseif os(iOS) || os(tvOS) || os(watchOS)
10 | import UIKit.UIFont
11 | #endif
12 |
13 | // Deprecated typealiases
14 | @available(*, deprecated, renamed: "{{fontType}}.Font", message: "This typealias will be removed in SwiftGen 7.0")
15 | {{accessModifier}} typealias {{param.fontAliasName|default:"Font"}} = {{fontType}}.Font
16 |
17 | // swiftlint:disable superfluous_disable_command
18 | // swiftlint:disable file_length
19 | // swiftlint:disable implicit_return
20 |
21 | // MARK: - Fonts
22 |
23 | // swiftlint:disable identifier_name line_length type_body_length
24 | {% macro transformPath path %}
25 | {%- if param.preservePath -%}
26 | {{path}}
27 | {%- else -%}
28 | {{path|basename}}
29 | {%- endif -%}
30 | {% endmacro %}
31 | {{accessModifier}} enum {{param.enumName|default:"FontFamily"}} {
32 | {% for family in families %}
33 | {{accessModifier}} enum {{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
34 | {% for font in family.fonts %}
35 | {{accessModifier}} static let {{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{fontType}}(name: "{{font.name}}", family: "{{family.name}}", path: "{% call transformPath font.path %}")
36 | {% endfor %}
37 | {{accessModifier}} static let all: [{{fontType}}] = [{% for font in family.fonts %}{{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{{ ", " if not forloop.last }}{% endfor %}]
38 | }
39 | {% endfor %}
40 | {{accessModifier}} static let allCustomFonts: [{{fontType}}] = [{% for family in families %}{{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}.all{{ ", " if not forloop.last }}{% endfor %}].flatMap { $0 }
41 | {{accessModifier}} static func registerAllCustomFonts() {
42 | allCustomFonts.forEach { $0.register() }
43 | }
44 | }
45 | // swiftlint:enable identifier_name line_length type_body_length
46 |
47 | // MARK: - Implementation Details
48 |
49 | {{accessModifier}} struct {{fontType}} {
50 | {{accessModifier}} let name: String
51 | {{accessModifier}} let family: String
52 | {{accessModifier}} let path: String
53 |
54 | #if os(macOS)
55 | {{accessModifier}} typealias Font = NSFont
56 | #elseif os(iOS) || os(tvOS) || os(watchOS)
57 | {{accessModifier}} typealias Font = UIFont
58 | #endif
59 |
60 | {{accessModifier}} func font(size: CGFloat) -> Font! {
61 | return Font(font: self, size: size)
62 | }
63 |
64 | {{accessModifier}} func register() {
65 | // swiftlint:disable:next conditional_returns_on_newline
66 | guard let url = url else { return }
67 | CTFontManagerRegisterFontsForURL(url as CFURL, .process, nil)
68 | }
69 |
70 | fileprivate var url: URL? {
71 | {% if param.lookupFunction %}
72 | return {{param.lookupFunction}}(name, family, path)
73 | {% else %}
74 | return {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil)
75 | {% endif %}
76 | }
77 | }
78 |
79 | {{accessModifier}} extension {{fontType}}.Font {
80 | convenience init?(font: {{fontType}}, size: CGFloat) {
81 | #if os(iOS) || os(tvOS) || os(watchOS)
82 | if !UIFont.fontNames(forFamilyName: font.family).contains(font.name) {
83 | font.register()
84 | }
85 | #elseif os(macOS)
86 | if let url = font.url, CTFontManagerGetScopeForURL(url as CFURL) == .none {
87 | font.register()
88 | }
89 | #endif
90 |
91 | self.init(name: font.name, size: size)
92 | }
93 | }
94 | {% if not param.bundle and not param.lookupFunction %}
95 |
96 | // swiftlint:disable convenience_type
97 | private final class BundleToken {
98 | static let bundle: Bundle = {
99 | #if SWIFT_PACKAGE
100 | return Bundle.module
101 | #else
102 | return Bundle(for: BundleToken.self)
103 | #endif
104 | }()
105 | }
106 | // swiftlint:enable convenience_type
107 | {% endif %}
108 | {% else %}
109 | // No fonts found
110 | {% endif %}
111 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/fonts/swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if families %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | {% set fontType %}{{param.fontTypeName|default:"FontConvertible"}}{% endset %}
7 | #if os(macOS)
8 | import AppKit.NSFont
9 | #elseif os(iOS) || os(tvOS) || os(watchOS)
10 | import UIKit.UIFont
11 | #endif
12 | #if canImport(SwiftUI)
13 | import SwiftUI
14 | #endif
15 |
16 | // Deprecated typealiases
17 | @available(*, deprecated, renamed: "{{fontType}}.Font", message: "This typealias will be removed in SwiftGen 7.0")
18 | {{accessModifier}} typealias {{param.fontAliasName|default:"Font"}} = {{fontType}}.Font
19 |
20 | // swiftlint:disable superfluous_disable_command file_length implicit_return
21 |
22 | // MARK: - Fonts
23 |
24 | // swiftlint:disable identifier_name line_length type_body_length
25 | {% macro transformPath path %}
26 | {%- if param.preservePath -%}
27 | {{path}}
28 | {%- else -%}
29 | {{path|basename}}
30 | {%- endif -%}
31 | {% endmacro %}
32 | {{accessModifier}} enum {{param.enumName|default:"FontFamily"}} {
33 | {% for family in families %}
34 | {{accessModifier}} enum {{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
35 | {% for font in family.fonts %}
36 | {{accessModifier}} static let {{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{fontType}}(name: "{{font.name}}", family: "{{family.name}}", path: "{% call transformPath font.path %}")
37 | {% endfor %}
38 | {{accessModifier}} static let all: [{{fontType}}] = [{% for font in family.fonts %}{{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{{ ", " if not forloop.last }}{% endfor %}]
39 | }
40 | {% endfor %}
41 | {{accessModifier}} static let allCustomFonts: [{{fontType}}] = [{% for family in families %}{{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}.all{{ ", " if not forloop.last }}{% endfor %}].flatMap { $0 }
42 | {{accessModifier}} static func registerAllCustomFonts() {
43 | allCustomFonts.forEach { $0.register() }
44 | }
45 | }
46 | // swiftlint:enable identifier_name line_length type_body_length
47 |
48 | // MARK: - Implementation Details
49 |
50 | {{accessModifier}} struct {{fontType}} {
51 | {{accessModifier}} let name: String
52 | {{accessModifier}} let family: String
53 | {{accessModifier}} let path: String
54 |
55 | #if os(macOS)
56 | {{accessModifier}} typealias Font = NSFont
57 | #elseif os(iOS) || os(tvOS) || os(watchOS)
58 | {{accessModifier}} typealias Font = UIFont
59 | #endif
60 |
61 | {{accessModifier}} func font(size: CGFloat) -> Font {
62 | guard let font = Font(font: self, size: size) else {
63 | fatalError("Unable to initialize font '\(name)' (\(family))")
64 | }
65 | return font
66 | }
67 |
68 | #if canImport(SwiftUI)
69 | @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
70 | {{accessModifier}} func swiftUIFont(size: CGFloat) -> SwiftUI.Font {
71 | return SwiftUI.Font.custom(self, size: size)
72 | }
73 |
74 | @available(iOS 14.0, tvOS 14.0, watchOS 7.0, macOS 11.0, *)
75 | {{accessModifier}} func swiftUIFont(fixedSize: CGFloat) -> SwiftUI.Font {
76 | return SwiftUI.Font.custom(self, fixedSize: fixedSize)
77 | }
78 |
79 | @available(iOS 14.0, tvOS 14.0, watchOS 7.0, macOS 11.0, *)
80 | {{accessModifier}} func swiftUIFont(size: CGFloat, relativeTo textStyle: SwiftUI.Font.TextStyle) -> SwiftUI.Font {
81 | return SwiftUI.Font.custom(self, size: size, relativeTo: textStyle)
82 | }
83 | #endif
84 |
85 | {{accessModifier}} func register() {
86 | // swiftlint:disable:next conditional_returns_on_newline
87 | guard let url = url else { return }
88 | CTFontManagerRegisterFontsForURL(url as CFURL, .process, nil)
89 | }
90 |
91 | fileprivate func registerIfNeeded() {
92 | #if os(iOS) || os(tvOS) || os(watchOS)
93 | if !UIFont.fontNames(forFamilyName: family).contains(name) {
94 | register()
95 | }
96 | #elseif os(macOS)
97 | if let url = url, CTFontManagerGetScopeForURL(url as CFURL) == .none {
98 | register()
99 | }
100 | #endif
101 | }
102 |
103 | fileprivate var url: URL? {
104 | // swiftlint:disable:next implicit_return
105 | {% if param.lookupFunction %}
106 | return {{param.lookupFunction}}(name, family, path)
107 | {% else %}
108 | return {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil)
109 | {% endif %}
110 | }
111 | }
112 |
113 | {{accessModifier}} extension {{fontType}}.Font {
114 | convenience init?(font: {{fontType}}, size: CGFloat) {
115 | font.registerIfNeeded()
116 | self.init(name: font.name, size: size)
117 | }
118 | }
119 |
120 | #if canImport(SwiftUI)
121 | @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
122 | {{accessModifier}} extension SwiftUI.Font {
123 | static func custom(_ font: {{fontType}}, size: CGFloat) -> SwiftUI.Font {
124 | font.registerIfNeeded()
125 | return custom(font.name, size: size)
126 | }
127 | }
128 |
129 | @available(iOS 14.0, tvOS 14.0, watchOS 7.0, macOS 11.0, *)
130 | {{accessModifier}} extension SwiftUI.Font {
131 | static func custom(_ font: {{fontType}}, fixedSize: CGFloat) -> SwiftUI.Font {
132 | font.registerIfNeeded()
133 | return custom(font.name, fixedSize: fixedSize)
134 | }
135 |
136 | static func custom(
137 | _ font: {{fontType}},
138 | size: CGFloat,
139 | relativeTo textStyle: SwiftUI.Font.TextStyle
140 | ) -> SwiftUI.Font {
141 | font.registerIfNeeded()
142 | return custom(font.name, size: size, relativeTo: textStyle)
143 | }
144 | }
145 | #endif
146 | {% if not param.bundle and not param.lookupFunction %}
147 |
148 | // swiftlint:disable convenience_type
149 | private final class BundleToken {
150 | static let bundle: Bundle = {
151 | #if SWIFT_PACKAGE
152 | return Bundle.module
153 | #else
154 | return Bundle(for: BundleToken.self)
155 | #endif
156 | }()
157 | }
158 | // swiftlint:enable convenience_type
159 | {% endif %}
160 | {% else %}
161 | // No fonts found
162 | {% endif %}
163 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/ib/scenes-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if platform and storyboards %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | {% set isAppKit %}{% if platform == "macOS" %}true{% endif %}{% endset %}
7 | {% set prefix %}{% if isAppKit %}NS{% else %}UI{% endif %}{% endset %}
8 | {% set controller %}{% if isAppKit %}Controller{% else %}ViewController{% endif %}{% endset %}
9 | // swiftlint:disable sorted_imports
10 | import Foundation
11 | {% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %}
12 | import {{module}}
13 | {% endfor %}
14 |
15 | // swiftlint:disable superfluous_disable_command
16 | // swiftlint:disable file_length implicit_return
17 |
18 | // MARK: - Storyboard Scenes
19 |
20 | // swiftlint:disable explicit_type_interface identifier_name line_length prefer_self_in_static_references
21 | // swiftlint:disable type_body_length type_name
22 | {% macro moduleName item %}
23 | {%- if item.moduleIsPlaceholder -%}
24 | {{ env.PRODUCT_MODULE_NAME|default:param.module }}
25 | {%- else -%}
26 | {{ item.module }}
27 | {%- endif -%}
28 | {% endmacro %}
29 | {% macro className item %}
30 | {%- set module %}{% call moduleName item %}{% endset -%}
31 | {%- if module and ( not param.ignoreTargetModule or module != env.PRODUCT_MODULE_NAME and module != param.module ) -%}
32 | {{module}}.
33 | {%- endif -%}
34 | {{item.type}}
35 | {%- endmacro %}
36 | {{accessModifier}} enum {{param.enumName|default:"StoryboardScene"}} {
37 | {% for storyboard in storyboards %}
38 | {% set storyboardName %}{{storyboard.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}{% endset %}
39 | {{accessModifier}} enum {{storyboardName}}: StoryboardType {
40 | {{accessModifier}} static let storyboardName = "{{storyboard.name}}"
41 | {% if storyboard.initialScene %}
42 |
43 | {% set sceneClass %}{% call className storyboard.initialScene %}{% endset %}
44 | {{accessModifier}} static let initialScene = InitialSceneType<{{sceneClass}}>(storyboard: {{storyboardName}}.self)
45 | {% endif %}
46 | {% for scene in storyboard.scenes %}
47 |
48 | {% set sceneID %}{{scene.identifier|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset %}
49 | {% set sceneClass %}{% call className scene %}{% endset %}
50 | {{accessModifier}} static let {{sceneID}} = SceneType<{{sceneClass}}>(storyboard: {{storyboardName}}.self, identifier: "{{scene.identifier}}")
51 | {% endfor %}
52 | }
53 | {% endfor %}
54 | }
55 | // swiftlint:enable explicit_type_interface identifier_name line_length prefer_self_in_static_references
56 | // swiftlint:enable type_body_length type_name
57 |
58 | // MARK: - Implementation Details
59 |
60 | {{accessModifier}} protocol StoryboardType {
61 | static var storyboardName: String { get }
62 | }
63 |
64 | {{accessModifier}} extension StoryboardType {
65 | static var storyboard: {{prefix}}Storyboard {
66 | let name = {%+ if isAppKit %}NSStoryboard.Name({% endif %}self.storyboardName{% if isAppKit %}){% endif +%}
67 | {% if param.lookupFunction %}
68 | return {{param.lookupFunction}}(name)
69 | {% else %}
70 | return {{prefix}}Storyboard(name: name, bundle: {{param.bundle|default:"BundleToken.bundle"}})
71 | {% endif %}
72 | }
73 | }
74 |
75 | {{accessModifier}} struct SceneType {
76 | {{accessModifier}} let storyboard: StoryboardType.Type
77 | {{accessModifier}} let identifier: String
78 |
79 | {{accessModifier}} func instantiate() -> T {
80 | let identifier = {%+ if isAppKit %}NSStoryboard.SceneIdentifier({% endif %}self.identifier{% if isAppKit %}){% endif +%}
81 | guard let controller = storyboard.storyboard.instantiate{{controller}}(withIdentifier: identifier) as? T else {
82 | fatalError("{{controller}} '\(identifier)' is not of the expected class \(T.self).")
83 | }
84 | return controller
85 | }
86 |
87 | {% if isAppKit %}
88 | @available(macOS 10.15, *)
89 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSViewController {
90 | return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
91 | }
92 |
93 | @available(macOS 10.15, *)
94 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSWindowController {
95 | return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
96 | }
97 | {% else %}
98 | @available(iOS 13.0, tvOS 13.0, *)
99 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T {
100 | return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
101 | }
102 | {% endif %}
103 | }
104 |
105 | {{accessModifier}} struct InitialSceneType {
106 | {{accessModifier}} let storyboard: StoryboardType.Type
107 |
108 | {{accessModifier}} func instantiate() -> T {
109 | guard let controller = storyboard.storyboard.instantiateInitial{{controller}}() as? T else {
110 | fatalError("{{controller}} is not of the expected class \(T.self).")
111 | }
112 | return controller
113 | }
114 |
115 | {% if isAppKit %}
116 | @available(macOS 10.15, *)
117 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSViewController {
118 | guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
119 | fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
120 | }
121 | return controller
122 | }
123 |
124 | @available(macOS 10.15, *)
125 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSWindowController {
126 | guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
127 | fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
128 | }
129 | return controller
130 | }
131 | {% else %}
132 | @available(iOS 13.0, tvOS 13.0, *)
133 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T {
134 | guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
135 | fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
136 | }
137 | return controller
138 | }
139 | {% endif %}
140 | }
141 | {% if not param.bundle and not param.lookupFunction %}
142 |
143 | // swiftlint:disable convenience_type
144 | private final class BundleToken {
145 | static let bundle: Bundle = {
146 | #if SWIFT_PACKAGE
147 | return Bundle.module
148 | #else
149 | return Bundle(for: BundleToken.self)
150 | #endif
151 | }()
152 | }
153 | // swiftlint:enable convenience_type
154 | {% endif %}
155 | {% elif storyboards %}
156 | // Mixed AppKit and UIKit storyboard files found, please invoke swiftgen with these separately
157 | {% else %}
158 | // No storyboard found
159 | {% endif %}
160 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/ib/scenes-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if platform and storyboards %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | {% set isAppKit %}{% if platform == "macOS" %}true{% endif %}{% endset %}
7 | {% set prefix %}{% if isAppKit %}NS{% else %}UI{% endif %}{% endset %}
8 | {% set controller %}{% if isAppKit %}Controller{% else %}ViewController{% endif %}{% endset %}
9 | // swiftlint:disable sorted_imports
10 | import Foundation
11 | {% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %}
12 | import {{module}}
13 | {% endfor %}
14 |
15 | // swiftlint:disable superfluous_disable_command
16 | // swiftlint:disable file_length implicit_return
17 |
18 | // MARK: - Storyboard Scenes
19 |
20 | // swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
21 | {% macro moduleName item %}
22 | {%- if item.moduleIsPlaceholder -%}
23 | {{ env.PRODUCT_MODULE_NAME|default:param.module }}
24 | {%- else -%}
25 | {{ item.module }}
26 | {%- endif -%}
27 | {% endmacro %}
28 | {% macro className item %}
29 | {%- set module %}{% call moduleName item %}{% endset -%}
30 | {%- if module and ( not param.ignoreTargetModule or module != env.PRODUCT_MODULE_NAME and module != param.module ) -%}
31 | {{module}}.
32 | {%- endif -%}
33 | {{item.type}}
34 | {%- endmacro %}
35 | {{accessModifier}} enum {{param.enumName|default:"StoryboardScene"}} {
36 | {% for storyboard in storyboards %}
37 | {% set storyboardName %}{{storyboard.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}{% endset %}
38 | {{accessModifier}} enum {{storyboardName}}: StoryboardType {
39 | {{accessModifier}} static let storyboardName = "{{storyboard.name}}"
40 | {% if storyboard.initialScene %}
41 |
42 | {% set sceneClass %}{% call className storyboard.initialScene %}{% endset %}
43 | {{accessModifier}} static let initialScene = InitialSceneType<{{sceneClass}}>(storyboard: Self.self)
44 | {% endif %}
45 | {% for scene in storyboard.scenes %}
46 |
47 | {% set sceneID %}{{scene.identifier|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset %}
48 | {% set sceneClass %}{% call className scene %}{% endset %}
49 | {{accessModifier}} static let {{sceneID}} = SceneType<{{sceneClass}}>(storyboard: Self.self, identifier: "{{scene.identifier}}")
50 | {% endfor %}
51 | }
52 | {% endfor %}
53 | }
54 | // swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
55 |
56 | // MARK: - Implementation Details
57 |
58 | {{accessModifier}} protocol StoryboardType {
59 | static var storyboardName: String { get }
60 | }
61 |
62 | {{accessModifier}} extension StoryboardType {
63 | static var storyboard: {{prefix}}Storyboard {
64 | let name = {%+ if isAppKit %}NSStoryboard.Name({% endif %}self.storyboardName{% if isAppKit %}){% endif +%}
65 | {% if param.lookupFunction %}
66 | return {{param.lookupFunction}}(name)
67 | {% else %}
68 | return {{prefix}}Storyboard(name: name, bundle: {{param.bundle|default:"BundleToken.bundle"}})
69 | {% endif %}
70 | }
71 | }
72 |
73 | {{accessModifier}} struct SceneType {
74 | {{accessModifier}} let storyboard: StoryboardType.Type
75 | {{accessModifier}} let identifier: String
76 |
77 | {{accessModifier}} func instantiate() -> T {
78 | let identifier = {%+ if isAppKit %}NSStoryboard.SceneIdentifier({% endif %}self.identifier{% if isAppKit %}){% endif +%}
79 | guard let controller = storyboard.storyboard.instantiate{{controller}}(withIdentifier: identifier) as? T else {
80 | fatalError("{{controller}} '\(identifier)' is not of the expected class \(T.self).")
81 | }
82 | return controller
83 | }
84 |
85 | {% if isAppKit %}
86 | @available(macOS 10.15, *)
87 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSViewController {
88 | let identifier = NSStoryboard.SceneIdentifier(self.identifier)
89 | return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
90 | }
91 |
92 | @available(macOS 10.15, *)
93 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSWindowController {
94 | let identifier = NSStoryboard.SceneIdentifier(self.identifier)
95 | return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
96 | }
97 | {% else %}
98 | @available(iOS 13.0, tvOS 13.0, *)
99 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T {
100 | return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
101 | }
102 | {% endif %}
103 | }
104 |
105 | {{accessModifier}} struct InitialSceneType {
106 | {{accessModifier}} let storyboard: StoryboardType.Type
107 |
108 | {{accessModifier}} func instantiate() -> T {
109 | guard let controller = storyboard.storyboard.instantiateInitial{{controller}}() as? T else {
110 | fatalError("{{controller}} is not of the expected class \(T.self).")
111 | }
112 | return controller
113 | }
114 |
115 | {% if isAppKit %}
116 | @available(macOS 10.15, *)
117 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSViewController {
118 | guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
119 | fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
120 | }
121 | return controller
122 | }
123 |
124 | @available(macOS 10.15, *)
125 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSWindowController {
126 | guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
127 | fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
128 | }
129 | return controller
130 | }
131 | {% else %}
132 | @available(iOS 13.0, tvOS 13.0, *)
133 | {{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T {
134 | guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
135 | fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
136 | }
137 | return controller
138 | }
139 | {% endif %}
140 | }
141 | {% if not param.bundle and not param.lookupFunction %}
142 |
143 | // swiftlint:disable convenience_type
144 | private final class BundleToken {
145 | static let bundle: Bundle = {
146 | #if SWIFT_PACKAGE
147 | return Bundle.module
148 | #else
149 | return Bundle(for: BundleToken.self)
150 | #endif
151 | }()
152 | }
153 | // swiftlint:enable convenience_type
154 | {% endif %}
155 | {% elif storyboards %}
156 | // Mixed AppKit and UIKit storyboard files found, please invoke swiftgen with these separately
157 | {% else %}
158 | // No storyboard found
159 | {% endif %}
160 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/ib/segues-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if platform and storyboards %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | {% set isAppKit %}{% if platform == "macOS" %}true{% endif %}{% endset %}
7 | // swiftlint:disable sorted_imports
8 | import Foundation
9 | {% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %}
10 | import {{module}}
11 | {% endfor %}
12 |
13 | // swiftlint:disable superfluous_disable_command
14 | // swiftlint:disable file_length
15 |
16 | // MARK: - Storyboard Segues
17 |
18 | // swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
19 | {{accessModifier}} enum {{param.enumName|default:"StoryboardSegue"}} {
20 | {% for storyboard in storyboards where storyboard.segues %}
21 | {{accessModifier}} enum {{storyboard.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}: String, SegueType {
22 | {% for segue in storyboard.segues %}
23 | {% set segueID %}{{segue.identifier|swiftIdentifier:"pretty"|lowerFirstWord}}{% endset %}
24 | case {{segueID|escapeReservedKeywords}}{% if segueID != segue.identifier %} = "{{segue.identifier}}"{% endif +%}
25 | {% endfor %}
26 | }
27 | {% endfor %}
28 | }
29 | // swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
30 |
31 | // MARK: - Implementation Details
32 |
33 | {{accessModifier}} protocol SegueType: RawRepresentable {}
34 |
35 | {{accessModifier}} extension {%+ if isAppKit %}NSSeguePerforming{% else %}UIViewController{% endif %} {
36 | func perform(segue: S, sender: Any? = nil) where S.RawValue == String {
37 | let identifier = {%+ if isAppKit %}NSStoryboardSegue.Identifier({% endif %}segue.rawValue{% if isAppKit %}){% endif +%}
38 | performSegue{% if isAppKit %}?{% endif %}(withIdentifier: identifier, sender: sender)
39 | }
40 | }
41 |
42 | {{accessModifier}} extension SegueType where RawValue == String {
43 | init?(_ segue: {%+ if isAppKit %}NS{% else %}UI{% endif %}StoryboardSegue) {
44 | {% if isAppKit %}
45 | #if swift(>=4.2)
46 | guard let identifier = segue.identifier else { return nil }
47 | #else
48 | guard let identifier = segue.identifier?.rawValue else { return nil }
49 | #endif
50 | {% else %}
51 | guard let identifier = segue.identifier else { return nil }
52 | {% endif %}
53 | self.init(rawValue: identifier)
54 | }
55 | }
56 | {% elif storyboards %}
57 | // Mixed AppKit and UIKit storyboard files found, please invoke swiftgen with these separately
58 | {% else %}
59 | // No storyboard found
60 | {% endif %}
61 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/ib/segues-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if platform and storyboards %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | {% set isAppKit %}{% if platform == "macOS" %}true{% endif %}{% endset %}
7 | // swiftlint:disable sorted_imports
8 | import Foundation
9 | {% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %}
10 | import {{module}}
11 | {% endfor %}
12 |
13 | // swiftlint:disable superfluous_disable_command
14 | // swiftlint:disable file_length
15 |
16 | // MARK: - Storyboard Segues
17 |
18 | // swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
19 | {{accessModifier}} enum {{param.enumName|default:"StoryboardSegue"}} {
20 | {% for storyboard in storyboards where storyboard.segues %}
21 | {{accessModifier}} enum {{storyboard.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}: String, SegueType {
22 | {% for segue in storyboard.segues %}
23 | {% set segueID %}{{segue.identifier|swiftIdentifier:"pretty"|lowerFirstWord}}{% endset %}
24 | case {{segueID|escapeReservedKeywords}}{% if segueID != segue.identifier %} = "{{segue.identifier}}"{% endif +%}
25 | {% endfor %}
26 | }
27 | {% endfor %}
28 | }
29 | // swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
30 |
31 | // MARK: - Implementation Details
32 |
33 | {{accessModifier}} protocol SegueType: RawRepresentable {}
34 |
35 | {{accessModifier}} extension {%+ if isAppKit %}NSSeguePerforming{% else %}UIViewController{% endif %} {
36 | func perform(segue: S, sender: Any? = nil) where S.RawValue == String {
37 | let identifier = {%+ if isAppKit %}NSStoryboardSegue.Identifier({% endif %}segue.rawValue{% if isAppKit %}){% endif +%}
38 | performSegue{% if isAppKit %}?{% endif %}(withIdentifier: identifier, sender: sender)
39 | }
40 | }
41 |
42 | {{accessModifier}} extension SegueType where RawValue == String {
43 | init?(_ segue: {%+ if isAppKit %}NS{% else %}UI{% endif %}StoryboardSegue) {
44 | {% if isAppKit %}
45 | #if swift(>=4.2)
46 | guard let identifier = segue.identifier else { return nil }
47 | #else
48 | guard let identifier = segue.identifier?.rawValue else { return nil }
49 | #endif
50 | {% else %}
51 | guard let identifier = segue.identifier else { return nil }
52 | {% endif %}
53 | self.init(rawValue: identifier)
54 | }
55 | }
56 | {% elif storyboards %}
57 | // Mixed AppKit and UIKit storyboard files found, please invoke swiftgen with these separately
58 | {% else %}
59 | // No storyboard found
60 | {% endif %}
61 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/json/inline-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command
9 | // swiftlint:disable file_length
10 |
11 | // MARK: - JSON Files
12 | {% macro fileBlock file %}
13 | {% call documentBlock file file.document %}
14 | {% endmacro %}
15 | {% macro documentBlock file document %}
16 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
17 | {% if document.metadata.type == "Array" %}
18 | {{accessModifier}} static let items: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
19 | {% elif document.metadata.type == "Dictionary" %}
20 | {% for key,value in document.metadata.properties %}
21 | {{accessModifier}} {%+ call propertyBlock key value document.data %}
22 | {% endfor %}
23 | {% else %}
24 | {{accessModifier}} static let value: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
25 | {% endif %}
26 | {% endmacro %}
27 | {% macro typeBlock metadata %}
28 | {%- if metadata.type == "Array" -%}
29 | [{% call typeBlock metadata.element %}]
30 | {%- elif metadata.type == "Dictionary" -%}
31 | [String: Any]
32 | {%- elif metadata.type == "Optional" -%}
33 | Any?
34 | {%- else -%}
35 | {{metadata.type}}
36 | {%- endif -%}
37 | {% endmacro %}
38 | {% macro propertyBlock key metadata data %}
39 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
40 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
41 | static let {{propertyName}}: {{propertyType}} = {%+ call valueBlock data[key] metadata +%}
42 | {% endmacro %}
43 | {% macro valueBlock value metadata %}
44 | {%- if metadata.type == "String" -%}
45 | "{{ value }}"
46 | {%- elif metadata.type == "Optional" -%}
47 | nil
48 | {%- elif metadata.type == "Array" and value -%}
49 | [{% for value in value -%}
50 | {%- call valueBlock value metadata.element.items[forloop.counter0]|default:metadata.element -%}
51 | {{ ", " if not forloop.last }}
52 | {%- endfor %}]
53 | {%- elif metadata.type == "Dictionary" -%}
54 | [{% for key,value in value -%}
55 | "{{key}}": {%+ call valueBlock value metadata.properties[key] -%}
56 | {{ ", " if not forloop.last }}
57 | {%- empty -%}
58 | :
59 | {%- endfor %}]
60 | {%- elif metadata.type == "Bool" -%}
61 | {%- if value %}true{% else %}false{% endif -%}
62 | {%- else -%}
63 | {{ value }}
64 | {%- endif -%}
65 | {% endmacro %}
66 |
67 | // swiftlint:disable identifier_name line_length number_separator type_body_length
68 | {{accessModifier}} enum {{param.enumName|default:"JSONFiles"}} {
69 | {% if files.count > 1 or param.forceFileNameEnum %}
70 | {% for file in files %}
71 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
72 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
73 | }
74 | {% endfor %}
75 | {% else %}
76 | {% call fileBlock files.first %}
77 | {% endif %}
78 | }
79 | // swiftlint:enable identifier_name line_length number_separator type_body_length
80 | {% else %}
81 | // No files found
82 | {% endif %}
83 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/json/inline-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command
9 | // swiftlint:disable file_length
10 |
11 | // MARK: - JSON Files
12 | {% macro fileBlock file %}
13 | {% call documentBlock file file.document %}
14 | {% endmacro %}
15 | {% macro documentBlock file document %}
16 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
17 | {% if document.metadata.type == "Array" %}
18 | {{accessModifier}} static let items: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
19 | {% elif document.metadata.type == "Dictionary" %}
20 | {% for key,value in document.metadata.properties %}
21 | {{accessModifier}} {%+ call propertyBlock key value document.data %}
22 | {% endfor %}
23 | {% else %}
24 | {{accessModifier}} static let value: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
25 | {% endif %}
26 | {% endmacro %}
27 | {% macro typeBlock metadata %}
28 | {%- if metadata.type == "Array" -%}
29 | [{% call typeBlock metadata.element %}]
30 | {%- elif metadata.type == "Dictionary" -%}
31 | [String: Any]
32 | {%- elif metadata.type == "Optional" -%}
33 | Any?
34 | {%- else -%}
35 | {{metadata.type}}
36 | {%- endif -%}
37 | {% endmacro %}
38 | {% macro propertyBlock key metadata data %}
39 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
40 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
41 | static let {{propertyName}}: {{propertyType}} = {%+ call valueBlock data[key] metadata +%}
42 | {% endmacro %}
43 | {% macro valueBlock value metadata %}
44 | {%- if metadata.type == "String" -%}
45 | "{{ value }}"
46 | {%- elif metadata.type == "Optional" -%}
47 | nil
48 | {%- elif metadata.type == "Array" and value -%}
49 | [{% for value in value -%}
50 | {%- call valueBlock value metadata.element.items[forloop.counter0]|default:metadata.element -%}
51 | {{ ", " if not forloop.last }}
52 | {%- endfor %}]
53 | {%- elif metadata.type == "Dictionary" -%}
54 | [{% for key,value in value -%}
55 | "{{key}}": {%+ call valueBlock value metadata.properties[key] -%}
56 | {{ ", " if not forloop.last }}
57 | {%- empty -%}
58 | :
59 | {%- endfor %}]
60 | {%- elif metadata.type == "Bool" -%}
61 | {%- if value %}true{% else %}false{% endif -%}
62 | {%- else -%}
63 | {{ value }}
64 | {%- endif -%}
65 | {% endmacro %}
66 |
67 | // swiftlint:disable identifier_name line_length number_separator type_body_length
68 | {{accessModifier}} enum {{param.enumName|default:"JSONFiles"}} {
69 | {% if files.count > 1 or param.forceFileNameEnum %}
70 | {% for file in files %}
71 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
72 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
73 | }
74 | {% endfor %}
75 | {% else %}
76 | {% call fileBlock files.first %}
77 | {% endif %}
78 | }
79 | // swiftlint:enable identifier_name line_length number_separator type_body_length
80 | {% else %}
81 | // No files found
82 | {% endif %}
83 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/json/runtime-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command
9 | // swiftlint:disable file_length
10 |
11 | // MARK: - JSON Files
12 | {% macro fileBlock file %}
13 | {% call documentBlock file file.document %}
14 | {% endmacro %}
15 | {% macro documentBlock file document %}
16 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
17 | {% if document.metadata.type == "Array" %}
18 | {{accessModifier}} static let items: {{rootType}} = objectFromJSON(at: "{% call transformPath file.path %}")
19 | {% elif document.metadata.type == "Dictionary" %}
20 | private static let _document = JSONDocument(path: "{% call transformPath file.path %}")
21 | {% for key,value in document.metadata.properties %}
22 | {{accessModifier}} {%+ call propertyBlock key value %}
23 | {% endfor %}
24 | {% else %}
25 | {{accessModifier}} static let value: {{rootType}} = objectFromJSON(at: "{% call transformPath file.path %}")
26 | {% endif %}
27 | {% endmacro %}
28 | {% macro typeBlock metadata %}
29 | {%- if metadata.type == "Array" -%}
30 | [{% call typeBlock metadata.element %}]
31 | {%- elif metadata.type == "Dictionary" -%}
32 | [String: Any]
33 | {%- elif metadata.type == "Optional" -%}
34 | Any?
35 | {%- else -%}
36 | {{metadata.type}}
37 | {%- endif -%}
38 | {% endmacro %}
39 | {% macro propertyBlock key metadata %}
40 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
41 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
42 | static let {{propertyName}}: {{propertyType}} = _document["{{key}}"]
43 | {% endmacro %}
44 | {% macro transformPath path %}
45 | {%- if param.preservePath -%}
46 | {{path}}
47 | {%- else -%}
48 | {{path|basename}}
49 | {%- endif -%}
50 | {% endmacro %}
51 |
52 | // swiftlint:disable identifier_name line_length type_body_length
53 | {{accessModifier}} enum {{param.enumName|default:"JSONFiles"}} {
54 | {% if files.count > 1 or param.forceFileNameEnum %}
55 | {% for file in files %}
56 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
57 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
58 | }
59 | {% endfor %}
60 | {% else %}
61 | {% call fileBlock files.first %}
62 | {% endif %}
63 | }
64 | // swiftlint:enable identifier_name line_length type_body_length
65 |
66 | // MARK: - Implementation Details
67 |
68 | private func objectFromJSON(at path: String) -> T {
69 | {% if param.lookupFunction %}
70 | guard let url = {{param.lookupFunction}}(path),
71 | {% else %}
72 | guard let url = {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil),
73 | {% endif %}
74 | let json = try? JSONSerialization.jsonObject(with: Data(contentsOf: url), options: []),
75 | let result = json as? T else {
76 | fatalError("Unable to load JSON at path: \(path)")
77 | }
78 | return result
79 | }
80 |
81 | private struct JSONDocument {
82 | let data: [String: Any]
83 |
84 | init(path: String) {
85 | self.data = objectFromJSON(at: path)
86 | }
87 |
88 | subscript(key: String) -> T {
89 | guard let result = data[key] as? T else {
90 | fatalError("Property '\(key)' is not of type \(T.self)")
91 | }
92 | return result
93 | }
94 | }
95 | {% if not param.bundle and not param.lookupFunction %}
96 |
97 | // swiftlint:disable convenience_type
98 | private final class BundleToken {
99 | static let bundle: Bundle = {
100 | #if SWIFT_PACKAGE
101 | return Bundle.module
102 | #else
103 | return Bundle(for: BundleToken.self)
104 | #endif
105 | }()
106 | }
107 | // swiftlint:enable convenience_type
108 | {% endif %}
109 | {% else %}
110 | // No files found
111 | {% endif %}
112 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/json/runtime-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command
9 | // swiftlint:disable file_length
10 |
11 | // MARK: - JSON Files
12 | {% macro fileBlock file %}
13 | {% call documentBlock file file.document %}
14 | {% endmacro %}
15 | {% macro documentBlock file document %}
16 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
17 | {% if document.metadata.type == "Array" %}
18 | {{accessModifier}} static let items: {{rootType}} = objectFromJSON(at: "{% call transformPath file.path %}")
19 | {% elif document.metadata.type == "Dictionary" %}
20 | private static let _document = JSONDocument(path: "{% call transformPath file.path %}")
21 | {% for key,value in document.metadata.properties %}
22 | {{accessModifier}} {%+ call propertyBlock key value %}
23 | {% endfor %}
24 | {% else %}
25 | {{accessModifier}} static let value: {{rootType}} = objectFromJSON(at: "{% call transformPath file.path %}")
26 | {% endif %}
27 | {% endmacro %}
28 | {% macro typeBlock metadata %}
29 | {%- if metadata.type == "Array" -%}
30 | [{% call typeBlock metadata.element %}]
31 | {%- elif metadata.type == "Dictionary" -%}
32 | [String: Any]
33 | {%- elif metadata.type == "Optional" -%}
34 | Any?
35 | {%- else -%}
36 | {{metadata.type}}
37 | {%- endif -%}
38 | {% endmacro %}
39 | {% macro propertyBlock key metadata %}
40 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
41 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
42 | static let {{propertyName}}: {{propertyType}} = _document["{{key}}"]
43 | {% endmacro %}
44 | {% macro transformPath path %}
45 | {%- if param.preservePath -%}
46 | {{path}}
47 | {%- else -%}
48 | {{path|basename}}
49 | {%- endif -%}
50 | {% endmacro %}
51 |
52 | // swiftlint:disable identifier_name line_length type_body_length
53 | {{accessModifier}} enum {{param.enumName|default:"JSONFiles"}} {
54 | {% if files.count > 1 or param.forceFileNameEnum %}
55 | {% for file in files %}
56 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
57 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
58 | }
59 | {% endfor %}
60 | {% else %}
61 | {% call fileBlock files.first %}
62 | {% endif %}
63 | }
64 | // swiftlint:enable identifier_name line_length type_body_length
65 |
66 | // MARK: - Implementation Details
67 |
68 | private func objectFromJSON(at path: String) -> T {
69 | {% if param.lookupFunction %}
70 | guard let url = {{param.lookupFunction}}(path),
71 | {% else %}
72 | guard let url = {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil),
73 | {% endif %}
74 | let json = try? JSONSerialization.jsonObject(with: Data(contentsOf: url), options: []),
75 | let result = json as? T else {
76 | fatalError("Unable to load JSON at path: \(path)")
77 | }
78 | return result
79 | }
80 |
81 | private struct JSONDocument {
82 | let data: [String: Any]
83 |
84 | init(path: String) {
85 | self.data = objectFromJSON(at: path)
86 | }
87 |
88 | subscript(key: String) -> T {
89 | guard let result = data[key] as? T else {
90 | fatalError("Property '\(key)' is not of type \(T.self)")
91 | }
92 | return result
93 | }
94 | }
95 | {% if not param.bundle and not param.lookupFunction %}
96 |
97 | // swiftlint:disable convenience_type
98 | private final class BundleToken {
99 | static let bundle: Bundle = {
100 | #if SWIFT_PACKAGE
101 | return Bundle.module
102 | #else
103 | return Bundle(for: BundleToken.self)
104 | #endif
105 | }()
106 | }
107 | // swiftlint:enable convenience_type
108 | {% endif %}
109 | {% else %}
110 | // No files found
111 | {% endif %}
112 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/plist/inline-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command
9 | // swiftlint:disable file_length
10 |
11 | // MARK: - Plist Files
12 | {% macro fileBlock file %}
13 | {% call documentBlock file file.document %}
14 | {% endmacro %}
15 | {% macro documentBlock file document %}
16 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
17 | {% if document.metadata.type == "Array" %}
18 | {{accessModifier}} static let items: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
19 | {% elif document.metadata.type == "Dictionary" %}
20 | {% for key,value in document.metadata.properties %}
21 | {{accessModifier}} {%+ call propertyBlock key value document.data %}
22 | {% endfor %}
23 | {% else %}
24 | {{accessModifier}} static let value: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
25 | {% endif %}
26 | {% endmacro %}
27 | {% macro typeBlock metadata %}
28 | {%- if metadata.type == "Array" -%}
29 | [{% call typeBlock metadata.element %}]
30 | {%- elif metadata.type == "Dictionary" -%}
31 | [String: Any]
32 | {%- else -%}
33 | {{metadata.type}}
34 | {%- endif -%}
35 | {% endmacro %}
36 | {% macro propertyBlock key metadata data %}
37 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
38 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
39 | static let {{propertyName}}: {{propertyType}} = {%+ call valueBlock data[key] metadata +%}
40 | {% endmacro %}
41 | {% macro valueBlock value metadata %}
42 | {%- if metadata.type == "String" -%}
43 | "{{ value }}"
44 | {%- elif metadata.type == "Date" -%}
45 | Date(timeIntervalSinceReferenceDate: {{ value.timeIntervalSinceReferenceDate }})
46 | {%- elif metadata.type == "Optional" -%}
47 | nil
48 | {%- elif metadata.type == "Array" and value -%}
49 | [{% for value in value -%}
50 | {%- call valueBlock value metadata.element.items[forloop.counter0]|default:metadata.element -%}
51 | {{ ", " if not forloop.last }}
52 | {%- endfor %}]
53 | {%- elif metadata.type == "Dictionary" -%}
54 | [{% for key,value in value -%}
55 | "{{key}}": {%+ call valueBlock value metadata.properties[key] -%}
56 | {{ ", " if not forloop.last }}
57 | {%- empty -%}
58 | :
59 | {%- endfor %}]
60 | {%- elif metadata.type == "Bool" -%}
61 | {%- if value %}true{% else %}false{% endif -%}
62 | {%- else -%}
63 | {{ value }}
64 | {%- endif -%}
65 | {% endmacro %}
66 |
67 | // swiftlint:disable identifier_name line_length number_separator type_body_length
68 | {{accessModifier}} enum {{param.enumName|default:"PlistFiles"}} {
69 | {% if files.count > 1 or param.forceFileNameEnum %}
70 | {% for file in files %}
71 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
72 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
73 | }
74 | {% endfor %}
75 | {% else %}
76 | {% call fileBlock files.first %}
77 | {% endif %}
78 | }
79 | // swiftlint:enable identifier_name line_length number_separator type_body_length
80 | {% else %}
81 | // No files found
82 | {% endif %}
83 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/plist/inline-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command
9 | // swiftlint:disable file_length
10 |
11 | // MARK: - Plist Files
12 | {% macro fileBlock file %}
13 | {% call documentBlock file file.document %}
14 | {% endmacro %}
15 | {% macro documentBlock file document %}
16 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
17 | {% if document.metadata.type == "Array" %}
18 | {{accessModifier}} static let items: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
19 | {% elif document.metadata.type == "Dictionary" %}
20 | {% for key,value in document.metadata.properties %}
21 | {{accessModifier}} {%+ call propertyBlock key value document.data %}
22 | {% endfor %}
23 | {% else %}
24 | {{accessModifier}} static let value: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
25 | {% endif %}
26 | {% endmacro %}
27 | {% macro typeBlock metadata %}
28 | {%- if metadata.type == "Array" -%}
29 | [{% call typeBlock metadata.element %}]
30 | {%- elif metadata.type == "Dictionary" -%}
31 | [String: Any]
32 | {%- else -%}
33 | {{metadata.type}}
34 | {%- endif -%}
35 | {% endmacro %}
36 | {% macro propertyBlock key metadata data %}
37 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
38 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
39 | static let {{propertyName}}: {{propertyType}} = {%+ call valueBlock data[key] metadata +%}
40 | {% endmacro %}
41 | {% macro valueBlock value metadata %}
42 | {%- if metadata.type == "String" -%}
43 | "{{ value }}"
44 | {%- elif metadata.type == "Date" -%}
45 | Date(timeIntervalSinceReferenceDate: {{ value.timeIntervalSinceReferenceDate }})
46 | {%- elif metadata.type == "Optional" -%}
47 | nil
48 | {%- elif metadata.type == "Array" and value -%}
49 | [{% for value in value -%}
50 | {%- call valueBlock value metadata.element.items[forloop.counter0]|default:metadata.element -%}
51 | {{ ", " if not forloop.last }}
52 | {%- endfor %}]
53 | {%- elif metadata.type == "Dictionary" -%}
54 | [{% for key,value in value -%}
55 | "{{key}}": {%+ call valueBlock value metadata.properties[key] -%}
56 | {{ ", " if not forloop.last }}
57 | {%- empty -%}
58 | :
59 | {%- endfor %}]
60 | {%- elif metadata.type == "Bool" -%}
61 | {%- if value %}true{% else %}false{% endif -%}
62 | {%- else -%}
63 | {{ value }}
64 | {%- endif -%}
65 | {% endmacro %}
66 |
67 | // swiftlint:disable identifier_name line_length number_separator type_body_length
68 | {{accessModifier}} enum {{param.enumName|default:"PlistFiles"}} {
69 | {% if files.count > 1 or param.forceFileNameEnum %}
70 | {% for file in files %}
71 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
72 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
73 | }
74 | {% endfor %}
75 | {% else %}
76 | {% call fileBlock files.first %}
77 | {% endif %}
78 | }
79 | // swiftlint:enable identifier_name line_length number_separator type_body_length
80 | {% else %}
81 | // No files found
82 | {% endif %}
83 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/plist/runtime-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command
9 | // swiftlint:disable file_length
10 |
11 | // MARK: - Plist Files
12 | {% macro fileBlock file %}
13 | {% call documentBlock file file.document %}
14 | {% endmacro %}
15 | {% macro documentBlock file document %}
16 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
17 | {% if document.metadata.type == "Array" %}
18 | {{accessModifier}} static let items: {{rootType}} = arrayFromPlist(at: "{% call transformPath file.path %}")
19 | {% elif document.metadata.type == "Dictionary" %}
20 | private static let _document = PlistDocument(path: "{% call transformPath file.path %}")
21 | {% for key,value in document.metadata.properties %}
22 | {{accessModifier}} {%+ call propertyBlock key value %}
23 | {% endfor %}
24 | {% else %}
25 | // Unsupported root type `{{rootType}}`
26 | {% endif %}
27 | {% endmacro %}
28 | {% macro typeBlock metadata %}
29 | {%- if metadata.type == "Array" -%}
30 | [{% call typeBlock metadata.element %}]
31 | {%- elif metadata.type == "Dictionary" -%}
32 | [String: Any]
33 | {%- else -%}
34 | {{metadata.type}}
35 | {%- endif -%}
36 | {% endmacro %}
37 | {% macro propertyBlock key metadata %}
38 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
39 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
40 | static let {{propertyName}}: {{propertyType}} = _document["{{key}}"]
41 | {% endmacro %}
42 | {% macro transformPath path %}
43 | {%- if param.preservePath -%}
44 | {{path}}
45 | {%- else -%}
46 | {{path|basename}}
47 | {%- endif -%}
48 | {% endmacro %}
49 |
50 | // swiftlint:disable identifier_name line_length type_body_length
51 | {{accessModifier}} enum {{param.enumName|default:"PlistFiles"}} {
52 | {% if files.count > 1 or param.forceFileNameEnum %}
53 | {% for file in files %}
54 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
55 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
56 | }
57 | {% endfor %}
58 | {% else %}
59 | {% call fileBlock files.first %}
60 | {% endif %}
61 | }
62 | // swiftlint:enable identifier_name line_length type_body_length
63 |
64 | // MARK: - Implementation Details
65 |
66 | private func arrayFromPlist(at path: String) -> [T] {
67 | {% if param.lookupFunction %}
68 | guard let url = {{param.lookupFunction}}(path),
69 | {% else %}
70 | guard let url = {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil),
71 | {% endif %}
72 | let data = NSArray(contentsOf: url) as? [T] else {
73 | fatalError("Unable to load PLIST at path: \(path)")
74 | }
75 | return data
76 | }
77 |
78 | private struct PlistDocument {
79 | let data: [String: Any]
80 |
81 | init(path: String) {
82 | {% if param.lookupFunction %}
83 | guard let url = {{param.lookupFunction}}(path),
84 | {% else %}
85 | guard let url = {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil),
86 | {% endif %}
87 | let data = NSDictionary(contentsOf: url) as? [String: Any] else {
88 | fatalError("Unable to load PLIST at path: \(path)")
89 | }
90 | self.data = data
91 | }
92 |
93 | subscript(key: String) -> T {
94 | guard let result = data[key] as? T else {
95 | fatalError("Property '\(key)' is not of type \(T.self)")
96 | }
97 | return result
98 | }
99 | }
100 | {% if not param.bundle and not param.lookupFunction %}
101 |
102 | // swiftlint:disable convenience_type
103 | private final class BundleToken {
104 | static let bundle: Bundle = {
105 | #if SWIFT_PACKAGE
106 | return Bundle.module
107 | #else
108 | return Bundle(for: BundleToken.self)
109 | #endif
110 | }()
111 | }
112 | // swiftlint:enable convenience_type
113 | {% endif %}
114 | {% else %}
115 | // No files found
116 | {% endif %}
117 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/plist/runtime-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command
9 | // swiftlint:disable file_length
10 |
11 | // MARK: - Plist Files
12 | {% macro fileBlock file %}
13 | {% call documentBlock file file.document %}
14 | {% endmacro %}
15 | {% macro documentBlock file document %}
16 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
17 | {% if document.metadata.type == "Array" %}
18 | {{accessModifier}} static let items: {{rootType}} = arrayFromPlist(at: "{% call transformPath file.path %}")
19 | {% elif document.metadata.type == "Dictionary" %}
20 | private static let _document = PlistDocument(path: "{% call transformPath file.path %}")
21 | {% for key,value in document.metadata.properties %}
22 | {{accessModifier}} {%+ call propertyBlock key value %}
23 | {% endfor %}
24 | {% else %}
25 | // Unsupported root type `{{rootType}}`
26 | {% endif %}
27 | {% endmacro %}
28 | {% macro typeBlock metadata %}
29 | {%- if metadata.type == "Array" -%}
30 | [{% call typeBlock metadata.element %}]
31 | {%- elif metadata.type == "Dictionary" -%}
32 | [String: Any]
33 | {%- else -%}
34 | {{metadata.type}}
35 | {%- endif -%}
36 | {% endmacro %}
37 | {% macro propertyBlock key metadata %}
38 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
39 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
40 | static let {{propertyName}}: {{propertyType}} = _document["{{key}}"]
41 | {% endmacro %}
42 | {% macro transformPath path %}
43 | {%- if param.preservePath -%}
44 | {{path}}
45 | {%- else -%}
46 | {{path|basename}}
47 | {%- endif -%}
48 | {% endmacro %}
49 |
50 | // swiftlint:disable identifier_name line_length type_body_length
51 | {{accessModifier}} enum {{param.enumName|default:"PlistFiles"}} {
52 | {% if files.count > 1 or param.forceFileNameEnum %}
53 | {% for file in files %}
54 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
55 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
56 | }
57 | {% endfor %}
58 | {% else %}
59 | {% call fileBlock files.first %}
60 | {% endif %}
61 | }
62 | // swiftlint:enable identifier_name line_length type_body_length
63 |
64 | // MARK: - Implementation Details
65 |
66 | private func arrayFromPlist(at path: String) -> [T] {
67 | {% if param.lookupFunction %}
68 | guard let url = {{param.lookupFunction}}(path),
69 | {% else %}
70 | guard let url = {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil),
71 | {% endif %}
72 | let data = NSArray(contentsOf: url) as? [T] else {
73 | fatalError("Unable to load PLIST at path: \(path)")
74 | }
75 | return data
76 | }
77 |
78 | private struct PlistDocument {
79 | let data: [String: Any]
80 |
81 | init(path: String) {
82 | {% if param.lookupFunction %}
83 | guard let url = {{param.lookupFunction}}(path),
84 | {% else %}
85 | guard let url = {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil),
86 | {% endif %}
87 | let data = NSDictionary(contentsOf: url) as? [String: Any] else {
88 | fatalError("Unable to load PLIST at path: \(path)")
89 | }
90 | self.data = data
91 | }
92 |
93 | subscript(key: String) -> T {
94 | guard let result = data[key] as? T else {
95 | fatalError("Property '\(key)' is not of type \(T.self)")
96 | }
97 | return result
98 | }
99 | }
100 | {% if not param.bundle and not param.lookupFunction %}
101 |
102 | // swiftlint:disable convenience_type
103 | private final class BundleToken {
104 | static let bundle: Bundle = {
105 | #if SWIFT_PACKAGE
106 | return Bundle.module
107 | #else
108 | return Bundle(for: BundleToken.self)
109 | #endif
110 | }()
111 | }
112 | // swiftlint:enable convenience_type
113 | {% endif %}
114 | {% else %}
115 | // No files found
116 | {% endif %}
117 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/strings/flat-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if tables.count > 0 %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command file_length implicit_return prefer_self_in_static_references
9 |
10 | // MARK: - Strings
11 |
12 | {% macro parametersBlock types %}
13 | {%- for type in types -%}
14 | {%- if type == "String" -%}
15 | _ p{{forloop.counter}}: Any
16 | {%- else -%}
17 | _ p{{forloop.counter}}: {{type}}
18 | {%- endif -%}
19 | {{ ", " if not forloop.last }}
20 | {%- endfor -%}
21 | {% endmacro %}
22 | {% macro argumentsBlock types %}
23 | {%- for type in types -%}
24 | {%- if type == "String" -%}
25 | String(describing: p{{forloop.counter}})
26 | {%- elif type == "UnsafeRawPointer" -%}
27 | Int(bitPattern: p{{forloop.counter}})
28 | {%- else -%}
29 | p{{forloop.counter}}
30 | {%- endif -%}
31 | {{ ", " if not forloop.last }}
32 | {%- endfor -%}
33 | {% endmacro %}
34 | {% macro recursiveBlock table item %}
35 | {% for string in item.strings %}
36 | {% if not param.noComments %}
37 | {% for line in string.comment|default:string.translation|split:"\n" %}
38 | /// {{line}}
39 | {% endfor %}
40 | {% endif %}
41 | {% set translation string.translation|replace:'"','\"'|replace:' ','\t' %}
42 | {% if string.types %}
43 | {{accessModifier}} static func {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}({% call parametersBlock string.types %}) -> String {
44 | return {{enumName}}.tr("{{table}}", "{{string.key}}", {%+ call argumentsBlock string.types %}, fallback: "{{translation}}")
45 | }
46 | {% elif param.lookupFunction %}
47 | {{accessModifier}} static var {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}: String { return {{enumName}}.tr("{{table}}", "{{string.key}}", fallback: "{{translation}}") }
48 | {% else %}
49 | {{accessModifier}} static let {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{enumName}}.tr("{{table}}", "{{string.key}}", fallback: "{{translation}}")
50 | {% endif %}
51 | {% endfor %}
52 | {% for child in item.children %}
53 | {% call recursiveBlock table child %}
54 | {% endfor %}
55 | {% endmacro %}
56 | // swiftlint:disable function_parameter_count identifier_name line_length type_body_length
57 | {% set enumName %}{{param.enumName|default:"L10n"}}{% endset %}
58 | {{accessModifier}} enum {{enumName}} {
59 | {% if tables.count > 1 or param.forceFileNameEnum %}
60 | {% for table in tables %}
61 | {{accessModifier}} enum {{table.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
62 | {% filter indent:2," ",true %}{% call recursiveBlock table.name table.levels %}{% endfilter %}
63 | }
64 | {% endfor %}
65 | {% else %}
66 | {% call recursiveBlock tables.first.name tables.first.levels %}
67 | {% endif %}
68 | }
69 | // swiftlint:enable function_parameter_count identifier_name line_length type_body_length
70 |
71 | // MARK: - Implementation Details
72 |
73 | extension {{enumName}} {
74 | private static func tr(_ table: String, _ key: String, _ args: CVarArg..., fallback value: String) -> String {
75 | {% if param.lookupFunction %}
76 | let format = {{ param.lookupFunction }}(key, table, value)
77 | {% else %}
78 | let format = {{param.bundle|default:"BundleToken.bundle"}}.localizedString(forKey: key, value: value, table: table)
79 | {% endif %}
80 | return String(format: format, locale: Locale.current, arguments: args)
81 | }
82 | }
83 | {% if not param.bundle and not param.lookupFunction %}
84 |
85 | // swiftlint:disable convenience_type
86 | private final class BundleToken {
87 | static let bundle: Bundle = {
88 | #if SWIFT_PACKAGE
89 | return Bundle.module
90 | #else
91 | return Bundle(for: BundleToken.self)
92 | #endif
93 | }()
94 | }
95 | // swiftlint:enable convenience_type
96 | {% endif %}
97 | {% else %}
98 | // No string found
99 | {% endif %}
100 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/strings/flat-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if tables.count > 0 %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command file_length implicit_return prefer_self_in_static_references
9 |
10 | // MARK: - Strings
11 |
12 | {% macro parametersBlock types %}
13 | {%- for type in types -%}
14 | {%- if type == "String" -%}
15 | _ p{{forloop.counter}}: Any
16 | {%- else -%}
17 | _ p{{forloop.counter}}: {{type}}
18 | {%- endif -%}
19 | {{ ", " if not forloop.last }}
20 | {%- endfor -%}
21 | {% endmacro %}
22 | {% macro argumentsBlock types %}
23 | {%- for type in types -%}
24 | {%- if type == "String" -%}
25 | String(describing: p{{forloop.counter}})
26 | {%- elif type == "UnsafeRawPointer" -%}
27 | Int(bitPattern: p{{forloop.counter}})
28 | {%- else -%}
29 | p{{forloop.counter}}
30 | {%- endif -%}
31 | {{ ", " if not forloop.last }}
32 | {%- endfor -%}
33 | {% endmacro %}
34 | {% macro recursiveBlock table item %}
35 | {% for string in item.strings %}
36 | {% if not param.noComments %}
37 | {% for line in string.comment|default:string.translation|split:"\n" %}
38 | /// {{line}}
39 | {% endfor %}
40 | {% endif %}
41 | {% set translation string.translation|replace:'"','\"'|replace:' ','\t' %}
42 | {% if string.types %}
43 | {{accessModifier}} static func {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}({% call parametersBlock string.types %}) -> String {
44 | return {{enumName}}.tr("{{table}}", "{{string.key}}", {%+ call argumentsBlock string.types %}, fallback: "{{translation}}")
45 | }
46 | {% elif param.lookupFunction %}
47 | {{accessModifier}} static var {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}: String { return {{enumName}}.tr("{{table}}", "{{string.key}}", fallback: "{{translation}}") }
48 | {% else %}
49 | {{accessModifier}} static let {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{enumName}}.tr("{{table}}", "{{string.key}}", fallback: "{{translation}}")
50 | {% endif %}
51 | {% endfor %}
52 | {% for child in item.children %}
53 | {% call recursiveBlock table child %}
54 | {% endfor %}
55 | {% endmacro %}
56 | // swiftlint:disable function_parameter_count identifier_name line_length type_body_length
57 | {% set enumName %}{{param.enumName|default:"L10n"}}{% endset %}
58 | {{accessModifier}} enum {{enumName}} {
59 | {% if tables.count > 1 or param.forceFileNameEnum %}
60 | {% for table in tables %}
61 | {{accessModifier}} enum {{table.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
62 | {% filter indent:2," ",true %}{% call recursiveBlock table.name table.levels %}{% endfilter %}
63 | }
64 | {% endfor %}
65 | {% else %}
66 | {% call recursiveBlock tables.first.name tables.first.levels %}
67 | {% endif %}
68 | }
69 | // swiftlint:enable function_parameter_count identifier_name line_length type_body_length
70 |
71 | // MARK: - Implementation Details
72 |
73 | extension {{enumName}} {
74 | private static func tr(_ table: String, _ key: String, _ args: CVarArg..., fallback value: String) -> String {
75 | {% if param.lookupFunction %}
76 | let format = {{ param.lookupFunction }}(key, table, value)
77 | {% else %}
78 | let format = {{param.bundle|default:"BundleToken.bundle"}}.localizedString(forKey: key, value: value, table: table)
79 | {% endif %}
80 | return String(format: format, locale: Locale.current, arguments: args)
81 | }
82 | }
83 | {% if not param.bundle and not param.lookupFunction %}
84 |
85 | // swiftlint:disable convenience_type
86 | private final class BundleToken {
87 | static let bundle: Bundle = {
88 | #if SWIFT_PACKAGE
89 | return Bundle.module
90 | #else
91 | return Bundle(for: BundleToken.self)
92 | #endif
93 | }()
94 | }
95 | // swiftlint:enable convenience_type
96 | {% endif %}
97 | {% else %}
98 | // No string found
99 | {% endif %}
100 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/strings/objc-h.stencil:
--------------------------------------------------------------------------------
1 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
2 |
3 | {% if tables.count > 0 %}
4 | #import
5 |
6 | NS_ASSUME_NONNULL_BEGIN
7 |
8 | {% macro parametersBlock types %}
9 | {%- for type in types -%}
10 | ({% call paramTranslate type %})p{{ forloop.counter }}{{ " :" if not forloop.last }}
11 | {%- endfor -%}
12 | {% endmacro %}
13 | {% macro argumentsBlock types %}
14 | {%- for type in types -%}
15 | p{{forloop.counter}}{{ ", " if not forloop.last }}
16 | {%- endfor -%}
17 | {% endmacro %}
18 | {% macro paramTranslate swiftType %}
19 | {%- if swiftType == "Any" -%}
20 | id
21 | {%- elif swiftType == "CChar" -%}
22 | char
23 | {%- elif swiftType == "Float" -%}
24 | float
25 | {%- elif swiftType == "Int" -%}
26 | NSInteger
27 | {%- elif swiftType == "String" -%}
28 | id
29 | {%- elif swiftType == "UnsafePointer" -%}
30 | char*
31 | {%- elif swiftType == "UnsafeRawPointer" -%}
32 | void*
33 | {%- else -%}
34 | objc-h.stencil is missing '{{swiftType}}'
35 | {%- endif -%}
36 | {% endmacro %}
37 | {% macro emitOneMethod table item %}
38 | {% for string in item.strings %}
39 | {% if not param.noComments %}
40 | {% for line in string.comment|default:string.translation|split:"\n" %}
41 | /// {{line}}
42 | {% endfor %}
43 | {% endif %}
44 | {% if string.types %}
45 | {% if string.types.count == 1 %}
46 | + (NSString*){{string.key|swiftIdentifier:"pretty"|lowerFirstWord}}WithValue:{% call parametersBlock string.types %};
47 | {% else %}
48 | + (NSString*){{string.key|swiftIdentifier:"pretty"|lowerFirstWord}}WithValues:{% call parametersBlock string.types %};
49 | {% endif %}
50 | {% else %}
51 | + (NSString*){{string.key|swiftIdentifier:"pretty"|lowerFirstWord}};
52 | {% endif %}
53 | {% endfor %}
54 | {% for child in item.children %}
55 | {% call emitOneMethod table child %}
56 | {% endfor %}
57 | {% endmacro %}
58 | {% for table in tables %}
59 | @interface {{ table.name }} : NSObject
60 | {% call emitOneMethod table.name table.levels %}
61 | @end
62 |
63 | {% endfor %}
64 |
65 | NS_ASSUME_NONNULL_END
66 | {% else %}
67 | // No strings found
68 | {% endif %}
69 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/strings/objc-m.stencil:
--------------------------------------------------------------------------------
1 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
2 |
3 | {% if tables.count > 0 %}
4 | #import "{{ param.headerName|default:"Localizable.h" }}"
5 | {% if not param.bundle %}
6 |
7 | @interface BundleToken : NSObject
8 | @end
9 |
10 | @implementation BundleToken
11 | @end
12 | {% endif %}
13 |
14 | #pragma clang diagnostic push
15 | #pragma clang diagnostic ignored "-Wformat-security"
16 |
17 | static NSString* tr(NSString *tableName, NSString *key, NSString *value, ...) {
18 | NSBundle *bundle = {{param.bundle|default:"[NSBundle bundleForClass:BundleToken.class]"}};
19 | NSString *format = [bundle localizedStringForKey:key value:value table:tableName];
20 | NSLocale *locale = [NSLocale currentLocale];
21 |
22 | va_list args;
23 | va_start(args, value);
24 | NSString *result = [[NSString alloc] initWithFormat:format locale:locale arguments:args];
25 | va_end(args);
26 |
27 | return result;
28 | };
29 | #pragma clang diagnostic pop
30 |
31 | {% macro parametersBlock types %}
32 | {%- for type in types -%}
33 | ({% call paramTranslate type %})p{{ forloop.counter }}{{ " :" if not forloop.last }}
34 | {%- endfor -%}
35 | {% endmacro %}
36 | {% macro argumentsBlock types %}
37 | {%- for type in types -%}
38 | p{{forloop.counter}}{{ ", " if not forloop.last }}
39 | {%- endfor -%}
40 | {% endmacro %}
41 | {% macro paramTranslate swiftType %}
42 | {%- if swiftType == "Any" -%}
43 | id
44 | {%- elif swiftType == "CChar" -%}
45 | char
46 | {%- elif swiftType == "Float" -%}
47 | float
48 | {%- elif swiftType == "Int" -%}
49 | NSInteger
50 | {%- elif swiftType == "String" -%}
51 | id
52 | {%- elif swiftType == "UnsafePointer" -%}
53 | char*
54 | {%- elif swiftType == "UnsafeRawPointer" -%}
55 | void*
56 | {%- else -%}
57 | objc-m.stencil is missing '{{swiftType}}'
58 | {%- endif -%}
59 | {% endmacro %}
60 | {% macro tableContents table item %}
61 | {% for string in item.strings %}
62 | {% if string.types %}
63 | {% if string.types.count == 1 %}
64 | + (NSString*){{string.key|swiftIdentifier:"pretty"|lowerFirstWord}}WithValue:{% call parametersBlock string.types +%}
65 | {% else %}
66 | + (NSString*){{string.key|swiftIdentifier:"pretty"|lowerFirstWord}}WithValues:{% call parametersBlock string.types +%}
67 | {% endif %}
68 | {
69 | return tr(@"{{table}}", @"{{string.key}}", @"{{string.translation|replace:'"','\"'|replace:' ','\t'}}", {%+ call argumentsBlock string.types %});
70 | }
71 | {% else %}
72 | + (NSString*){{string.key|swiftIdentifier:"pretty"|lowerFirstWord}} {
73 | return tr(@"{{table}}", @"{{string.key}}", @"{{string.translation|replace:'"','\"'|replace:' ','\t'}}");
74 | }
75 | {% endif %}
76 | {% endfor %}
77 | {% for child in item.children %}
78 | {% call tableContents table child %}
79 | {% endfor %}
80 | {% endmacro %}
81 | {% for table in tables %}
82 | {% set tableName %}{{table.name|default:"Localized"}}{% endset %}
83 | @implementation {{ tableName }} : NSObject
84 | {% call tableContents table.name table.levels %}
85 | @end
86 |
87 | {% endfor %}
88 | {% else %}
89 | // No strings found
90 | {% endif %}
91 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/strings/structured-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if tables.count > 0 %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command file_length implicit_return prefer_self_in_static_references
9 |
10 | // MARK: - Strings
11 |
12 | {% macro parametersBlock types %}
13 | {%- for type in types -%}
14 | {%- if type == "String" -%}
15 | _ p{{forloop.counter}}: Any
16 | {%- else -%}
17 | _ p{{forloop.counter}}: {{type}}
18 | {%- endif -%}
19 | {{ ", " if not forloop.last }}
20 | {%- endfor -%}
21 | {% endmacro %}
22 | {% macro argumentsBlock types %}
23 | {%- for type in types -%}
24 | {%- if type == "String" -%}
25 | String(describing: p{{forloop.counter}})
26 | {%- elif type == "UnsafeRawPointer" -%}
27 | Int(bitPattern: p{{forloop.counter}})
28 | {%- else -%}
29 | p{{forloop.counter}}
30 | {%- endif -%}
31 | {{ ", " if not forloop.last }}
32 | {%- endfor -%}
33 | {% endmacro %}
34 | {% macro recursiveBlock table item %}
35 | {% for string in item.strings %}
36 | {% if not param.noComments %}
37 | {% for line in string.comment|default:string.translation|split:"\n" %}
38 | /// {{line}}
39 | {% endfor %}
40 | {% endif %}
41 | {% set translation string.translation|replace:'"','\"'|replace:' ','\t' %}
42 | {% if string.types %}
43 | {{accessModifier}} static func {{string.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}({% call parametersBlock string.types %}) -> String {
44 | return {{enumName}}.tr("{{table}}", "{{string.key}}", {%+ call argumentsBlock string.types %}, fallback: "{{translation}}")
45 | }
46 | {% elif param.lookupFunction %}
47 | {{accessModifier}} static var {{string.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}: String { return {{enumName}}.tr("{{table}}", "{{string.key}}", fallback: "{{translation}}") }
48 | {% else %}
49 | {{accessModifier}} static let {{string.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{enumName}}.tr("{{table}}", "{{string.key}}", fallback: "{{translation}}")
50 | {% endif %}
51 | {% endfor %}
52 | {% for child in item.children %}
53 | {{accessModifier}} enum {{child.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
54 | {% filter indent:2," ",true %}{% call recursiveBlock table child %}{% endfilter %}
55 | }
56 | {% endfor %}
57 | {% endmacro %}
58 | // swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
59 | // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
60 | {% set enumName %}{{param.enumName|default:"L10n"}}{% endset %}
61 | {{accessModifier}} enum {{enumName}} {
62 | {% if tables.count > 1 or param.forceFileNameEnum %}
63 | {% for table in tables %}
64 | {{accessModifier}} enum {{table.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
65 | {% filter indent:2," ",true %}{% call recursiveBlock table.name table.levels %}{% endfilter %}
66 | }
67 | {% endfor %}
68 | {% else %}
69 | {% call recursiveBlock tables.first.name tables.first.levels %}
70 | {% endif %}
71 | }
72 | // swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length
73 | // swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
74 |
75 | // MARK: - Implementation Details
76 |
77 | extension {{enumName}} {
78 | private static func tr(_ table: String, _ key: String, _ args: CVarArg..., fallback value: String) -> String {
79 | {% if param.lookupFunction %}
80 | let format = {{ param.lookupFunction }}(key, table, value)
81 | {% else %}
82 | let format = {{param.bundle|default:"BundleToken.bundle"}}.localizedString(forKey: key, value: value, table: table)
83 | {% endif %}
84 | return String(format: format, locale: Locale.current, arguments: args)
85 | }
86 | }
87 | {% if not param.bundle and not param.lookupFunction %}
88 |
89 | // swiftlint:disable convenience_type
90 | private final class BundleToken {
91 | static let bundle: Bundle = {
92 | #if SWIFT_PACKAGE
93 | return Bundle.module
94 | #else
95 | return Bundle(for: BundleToken.self)
96 | #endif
97 | }()
98 | }
99 | // swiftlint:enable convenience_type
100 | {% endif %}
101 | {% else %}
102 | // No string found
103 | {% endif %}
104 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/strings/structured-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if tables.count > 0 %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | import Foundation
7 |
8 | // swiftlint:disable superfluous_disable_command file_length implicit_return prefer_self_in_static_references
9 |
10 | // MARK: - Strings
11 |
12 | {% macro parametersBlock types %}
13 | {%- for type in types -%}
14 | {%- if type == "String" -%}
15 | _ p{{forloop.counter}}: Any
16 | {%- else -%}
17 | _ p{{forloop.counter}}: {{type}}
18 | {%- endif -%}
19 | {{ ", " if not forloop.last }}
20 | {%- endfor -%}
21 | {% endmacro %}
22 | {% macro argumentsBlock types %}
23 | {%- for type in types -%}
24 | {%- if type == "String" -%}
25 | String(describing: p{{forloop.counter}})
26 | {%- elif type == "UnsafeRawPointer" -%}
27 | Int(bitPattern: p{{forloop.counter}})
28 | {%- else -%}
29 | p{{forloop.counter}}
30 | {%- endif -%}
31 | {{ ", " if not forloop.last }}
32 | {%- endfor -%}
33 | {% endmacro %}
34 | {% macro recursiveBlock table item %}
35 | {% for string in item.strings %}
36 | {% if not param.noComments %}
37 | {% for line in string.comment|default:string.translation|split:"\n" %}
38 | /// {{line}}
39 | {% endfor %}
40 | {% endif %}
41 | {% set translation string.translation|replace:'"','\"'|replace:' ','\t' %}
42 | {% if string.types %}
43 | {{accessModifier}} static func {{string.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}({% call parametersBlock string.types %}) -> String {
44 | return {{enumName}}.tr("{{table}}", "{{string.key}}", {%+ call argumentsBlock string.types %}, fallback: "{{translation}}")
45 | }
46 | {% elif param.lookupFunction %}
47 | {{accessModifier}} static var {{string.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}: String { return {{enumName}}.tr("{{table}}", "{{string.key}}", fallback: "{{translation}}") }
48 | {% else %}
49 | {{accessModifier}} static let {{string.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{enumName}}.tr("{{table}}", "{{string.key}}", fallback: "{{translation}}")
50 | {% endif %}
51 | {% endfor %}
52 | {% for child in item.children %}
53 | {{accessModifier}} enum {{child.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
54 | {% filter indent:2," ",true %}{% call recursiveBlock table child %}{% endfilter %}
55 | }
56 | {% endfor %}
57 | {% endmacro %}
58 | // swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
59 | // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
60 | {% set enumName %}{{param.enumName|default:"L10n"}}{% endset %}
61 | {{accessModifier}} enum {{enumName}} {
62 | {% if tables.count > 1 or param.forceFileNameEnum %}
63 | {% for table in tables %}
64 | {{accessModifier}} enum {{table.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
65 | {% filter indent:2," ",true %}{% call recursiveBlock table.name table.levels %}{% endfilter %}
66 | }
67 | {% endfor %}
68 | {% else %}
69 | {% call recursiveBlock tables.first.name tables.first.levels %}
70 | {% endif %}
71 | }
72 | // swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length
73 | // swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
74 |
75 | // MARK: - Implementation Details
76 |
77 | extension {{enumName}} {
78 | private static func tr(_ table: String, _ key: String, _ args: CVarArg..., fallback value: String) -> String {
79 | {% if param.lookupFunction %}
80 | let format = {{ param.lookupFunction }}(key, table, value)
81 | {% else %}
82 | let format = {{param.bundle|default:"BundleToken.bundle"}}.localizedString(forKey: key, value: value, table: table)
83 | {% endif %}
84 | return String(format: format, locale: Locale.current, arguments: args)
85 | }
86 | }
87 | {% if not param.bundle and not param.lookupFunction %}
88 |
89 | // swiftlint:disable convenience_type
90 | private final class BundleToken {
91 | static let bundle: Bundle = {
92 | #if SWIFT_PACKAGE
93 | return Bundle.module
94 | #else
95 | return Bundle(for: BundleToken.self)
96 | #endif
97 | }()
98 | }
99 | // swiftlint:enable convenience_type
100 | {% endif %}
101 | {% else %}
102 | // No string found
103 | {% endif %}
104 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/yaml/inline-swift4.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | {% set documentPrefix %}{{param.documentName|default:"Document"}}{% endset %}
7 | import Foundation
8 |
9 | // swiftlint:disable superfluous_disable_command
10 | // swiftlint:disable file_length
11 |
12 | // MARK: - YAML Files
13 | {% macro fileBlock file %}
14 | {% if file.documents.count > 1 %}
15 | {% for document in file.documents %}
16 | {% set documentName %}{{documentPrefix}}{{forloop.counter}}{% endset %}
17 | {{accessModifier}} enum {{documentName|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
18 | {% filter indent:2," ",true %}{% call documentBlock file document %}{% endfilter %}
19 | }
20 | {% endfor %}
21 | {% else %}
22 | {% call documentBlock file file.documents.first %}
23 | {% endif %}
24 | {% endmacro %}
25 | {% macro documentBlock file document %}
26 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
27 | {% if document.metadata.type == "Array" %}
28 | {{accessModifier}} static let items: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
29 | {% elif document.metadata.type == "Dictionary" %}
30 | {% for key,value in document.metadata.properties %}
31 | {{accessModifier}} {%+ call propertyBlock key value document.data %}
32 | {% endfor %}
33 | {% else %}
34 | {{accessModifier}} static let value: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
35 | {% endif %}
36 | {% endmacro %}
37 | {% macro typeBlock metadata %}
38 | {%- if metadata.type == "Array" -%}
39 | [{% call typeBlock metadata.element %}]
40 | {%- elif metadata.type == "Dictionary" -%}
41 | [String: Any]
42 | {%- elif metadata.type == "Optional" -%}
43 | Any?
44 | {%- else -%}
45 | {{metadata.type}}
46 | {%- endif -%}
47 | {% endmacro %}
48 | {% macro propertyBlock key metadata data %}
49 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
50 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
51 | static let {{propertyName}}: {{propertyType}} = {%+ call valueBlock data[key] metadata +%}
52 | {% endmacro %}
53 | {% macro valueBlock value metadata %}
54 | {%- if metadata.type == "String" -%}
55 | "{{ value }}"
56 | {%- elif metadata.type == "Optional" -%}
57 | nil
58 | {%- elif metadata.type == "Array" and value -%}
59 | [{% for value in value -%}
60 | {%- call valueBlock value metadata.element.items[forloop.counter0]|default:metadata.element -%}
61 | {{ ", " if not forloop.last }}
62 | {%- endfor %}]
63 | {%- elif metadata.type == "Dictionary" -%}
64 | [{% for key,value in value -%}
65 | "{{key}}": {%+ call valueBlock value metadata.properties[key] -%}
66 | {{ ", " if not forloop.last }}
67 | {%- empty -%}
68 | :
69 | {%- endfor %}]
70 | {%- elif metadata.type == "Bool" -%}
71 | {%- if value %}true{% else %}false{% endif -%}
72 | {%- else -%}
73 | {{ value }}
74 | {%- endif -%}
75 | {% endmacro %}
76 |
77 | // swiftlint:disable identifier_name line_length number_separator type_body_length
78 | {{accessModifier}} enum {{param.enumName|default:"YAMLFiles"}} {
79 | {% if files.count > 1 or param.forceFileNameEnum %}
80 | {% for file in files %}
81 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
82 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
83 | }
84 | {% endfor %}
85 | {% else %}
86 | {% call fileBlock files.first %}
87 | {% endif %}
88 | }
89 | // swiftlint:enable identifier_name line_length number_separator type_body_length
90 | {% else %}
91 | // No files found
92 | {% endif %}
93 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/SwiftGen_SwiftGenCLI.bundle/Contents/Resources/templates/yaml/inline-swift5.stencil:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | {% if files %}
5 | {% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
6 | {% set documentPrefix %}{{param.documentName|default:"Document"}}{% endset %}
7 | import Foundation
8 |
9 | // swiftlint:disable superfluous_disable_command
10 | // swiftlint:disable file_length
11 |
12 | // MARK: - YAML Files
13 | {% macro fileBlock file %}
14 | {% if file.documents.count > 1 %}
15 | {% for document in file.documents %}
16 | {% set documentName %}{{documentPrefix}}{{forloop.counter}}{% endset %}
17 | {{accessModifier}} enum {{documentName|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
18 | {% filter indent:2," ",true %}{% call documentBlock file document %}{% endfilter %}
19 | }
20 | {% endfor %}
21 | {% else %}
22 | {% call documentBlock file file.documents.first %}
23 | {% endif %}
24 | {% endmacro %}
25 | {% macro documentBlock file document %}
26 | {% set rootType %}{% call typeBlock document.metadata %}{% endset %}
27 | {% if document.metadata.type == "Array" %}
28 | {{accessModifier}} static let items: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
29 | {% elif document.metadata.type == "Dictionary" %}
30 | {% for key,value in document.metadata.properties %}
31 | {{accessModifier}} {%+ call propertyBlock key value document.data %}
32 | {% endfor %}
33 | {% else %}
34 | {{accessModifier}} static let value: {{rootType}} = {%+ call valueBlock document.data document.metadata +%}
35 | {% endif %}
36 | {% endmacro %}
37 | {% macro typeBlock metadata %}
38 | {%- if metadata.type == "Array" -%}
39 | [{% call typeBlock metadata.element %}]
40 | {%- elif metadata.type == "Dictionary" -%}
41 | [String: Any]
42 | {%- elif metadata.type == "Optional" -%}
43 | Any?
44 | {%- else -%}
45 | {{metadata.type}}
46 | {%- endif -%}
47 | {% endmacro %}
48 | {% macro propertyBlock key metadata data %}
49 | {%- set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset -%}
50 | {%- set propertyType %}{% call typeBlock metadata %}{% endset -%}
51 | static let {{propertyName}}: {{propertyType}} = {%+ call valueBlock data[key] metadata +%}
52 | {% endmacro %}
53 | {% macro valueBlock value metadata %}
54 | {%- if metadata.type == "String" -%}
55 | "{{ value }}"
56 | {%- elif metadata.type == "Optional" -%}
57 | nil
58 | {%- elif metadata.type == "Array" and value -%}
59 | [{% for value in value -%}
60 | {%- call valueBlock value metadata.element.items[forloop.counter0]|default:metadata.element -%}
61 | {{ ", " if not forloop.last }}
62 | {%- endfor %}]
63 | {%- elif metadata.type == "Dictionary" -%}
64 | [{% for key,value in value -%}
65 | "{{key}}": {%+ call valueBlock value metadata.properties[key] -%}
66 | {{ ", " if not forloop.last }}
67 | {%- empty -%}
68 | :
69 | {%- endfor %}]
70 | {%- elif metadata.type == "Bool" -%}
71 | {%- if value %}true{% else %}false{% endif -%}
72 | {%- else -%}
73 | {{ value }}
74 | {%- endif -%}
75 | {% endmacro %}
76 |
77 | // swiftlint:disable identifier_name line_length number_separator type_body_length
78 | {{accessModifier}} enum {{param.enumName|default:"YAMLFiles"}} {
79 | {% if files.count > 1 or param.forceFileNameEnum %}
80 | {% for file in files %}
81 | {{accessModifier}} enum {{file.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
82 | {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
83 | }
84 | {% endfor %}
85 | {% else %}
86 | {% call fileBlock files.first %}
87 | {% endif %}
88 | }
89 | // swiftlint:enable identifier_name line_length number_separator type_body_length
90 | {% else %}
91 | // No files found
92 | {% endif %}
93 |
--------------------------------------------------------------------------------
/Example/Pods/SwiftGen/bin/swiftgen:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/Example/Pods/SwiftGen/bin/swiftgen
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/HDTranslateModule/HDTranslateModule-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 0.1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/HDTranslateModule/HDTranslateModule-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_HDTranslateModule : NSObject
3 | @end
4 | @implementation PodsDummy_HDTranslateModule
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/HDTranslateModule/HDTranslateModule-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/HDTranslateModule/HDTranslateModule-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 | #import "JDLTAttributedString.h"
14 | #import "JDLTTranslateHook.h"
15 | #import "JDLTTranslateManager.h"
16 | #import "JDLTTranslateModule.h"
17 |
18 | FOUNDATION_EXPORT double HDTranslateModuleVersionNumber;
19 | FOUNDATION_EXPORT const unsigned char HDTranslateModuleVersionString[];
20 |
21 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/HDTranslateModule/HDTranslateModule.debug.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../..
8 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
10 | SKIP_INSTALL = YES
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/HDTranslateModule/HDTranslateModule.modulemap:
--------------------------------------------------------------------------------
1 | framework module HDTranslateModule {
2 | umbrella header "HDTranslateModule-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/HDTranslateModule/HDTranslateModule.release.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../..
8 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
10 | SKIP_INSTALL = YES
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Example/Pods-HDTranslateModule_Example-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Example/Pods-HDTranslateModule_Example-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## HDTranslateModule
5 |
6 | Copyright (c) 2023 denglibing <328418417@qq.com>
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 |
26 |
27 | ## SwiftGen
28 |
29 | MIT Licence
30 |
31 | Copyright (c) 2022 SwiftGen
32 |
33 | Permission is hereby granted, free of charge, to any person obtaining a copy
34 | of this software and associated documentation files (the "Software"), to deal
35 | in the Software without restriction, including without limitation the rights
36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37 | copies of the Software, and to permit persons to whom the Software is
38 | furnished to do so, subject to the following conditions:
39 |
40 | The above copyright notice and this permission notice shall be included in all
41 | copies or substantial portions of the Software.
42 |
43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49 | SOFTWARE.
50 |
51 | Generated by CocoaPods - https://cocoapods.org
52 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Example/Pods-HDTranslateModule_Example-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Copyright (c) 2023 denglibing <328418417@qq.com>
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is
24 | furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in
27 | all copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.
36 |
37 | License
38 | MIT
39 | Title
40 | HDTranslateModule
41 | Type
42 | PSGroupSpecifier
43 |
44 |
45 | FooterText
46 | MIT Licence
47 |
48 | Copyright (c) 2022 SwiftGen
49 |
50 | Permission is hereby granted, free of charge, to any person obtaining a copy
51 | of this software and associated documentation files (the "Software"), to deal
52 | in the Software without restriction, including without limitation the rights
53 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
54 | copies of the Software, and to permit persons to whom the Software is
55 | furnished to do so, subject to the following conditions:
56 |
57 | The above copyright notice and this permission notice shall be included in all
58 | copies or substantial portions of the Software.
59 |
60 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
63 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
64 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
65 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
66 | SOFTWARE.
67 |
68 | License
69 | MIT
70 | Title
71 | SwiftGen
72 | Type
73 | PSGroupSpecifier
74 |
75 |
76 | FooterText
77 | Generated by CocoaPods - https://cocoapods.org
78 | Title
79 |
80 | Type
81 | PSGroupSpecifier
82 |
83 |
84 | StringsTable
85 | Acknowledgements
86 | Title
87 | Acknowledgements
88 |
89 |
90 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Example/Pods-HDTranslateModule_Example-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_HDTranslateModule_Example : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_HDTranslateModule_Example
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Example/Pods-HDTranslateModule_Example-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
14 | FOUNDATION_EXPORT double Pods_HDTranslateModule_ExampleVersionNumber;
15 | FOUNDATION_EXPORT const unsigned char Pods_HDTranslateModule_ExampleVersionString[];
16 |
17 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Example/Pods-HDTranslateModule_Example.debug.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule/HDTranslateModule.framework/Headers"
5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
6 | OTHER_LDFLAGS = $(inherited) -framework "HDTranslateModule"
7 | PODS_BUILD_DIR = ${BUILD_DIR}
8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
10 | PODS_ROOT = ${SRCROOT}/Pods
11 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
13 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Example/Pods-HDTranslateModule_Example.modulemap:
--------------------------------------------------------------------------------
1 | framework module Pods_HDTranslateModule_Example {
2 | umbrella header "Pods-HDTranslateModule_Example-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Example/Pods-HDTranslateModule_Example.release.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule/HDTranslateModule.framework/Headers"
5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
6 | OTHER_LDFLAGS = $(inherited) -framework "HDTranslateModule"
7 | PODS_BUILD_DIR = ${BUILD_DIR}
8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
10 | PODS_ROOT = ${SRCROOT}/Pods
11 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
13 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Tests/Pods-HDTranslateModule_Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Tests/Pods-HDTranslateModule_Tests-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 | Generated by CocoaPods - https://cocoapods.org
4 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Tests/Pods-HDTranslateModule_Tests-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Generated by CocoaPods - https://cocoapods.org
18 | Title
19 |
20 | Type
21 | PSGroupSpecifier
22 |
23 |
24 | StringsTable
25 | Acknowledgements
26 | Title
27 | Acknowledgements
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Tests/Pods-HDTranslateModule_Tests-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_HDTranslateModule_Tests : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_HDTranslateModule_Tests
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Tests/Pods-HDTranslateModule_Tests-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
14 | FOUNDATION_EXPORT double Pods_HDTranslateModule_TestsVersionNumber;
15 | FOUNDATION_EXPORT const unsigned char Pods_HDTranslateModule_TestsVersionString[];
16 |
17 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Tests/Pods-HDTranslateModule_Tests.debug.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule/HDTranslateModule.framework/Headers"
5 | OTHER_LDFLAGS = $(inherited) -framework "HDTranslateModule"
6 | PODS_BUILD_DIR = ${BUILD_DIR}
7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
9 | PODS_ROOT = ${SRCROOT}/Pods
10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Tests/Pods-HDTranslateModule_Tests.modulemap:
--------------------------------------------------------------------------------
1 | framework module Pods_HDTranslateModule_Tests {
2 | umbrella header "Pods-HDTranslateModule_Tests-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-HDTranslateModule_Tests/Pods-HDTranslateModule_Tests.release.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/HDTranslateModule/HDTranslateModule.framework/Headers"
5 | OTHER_LDFLAGS = $(inherited) -framework "HDTranslateModule"
6 | PODS_BUILD_DIR = ${BUILD_DIR}
7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
9 | PODS_ROOT = ${SRCROOT}/Pods
10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/SwiftGen/SwiftGen.debug.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SwiftGen
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/SwiftGen
8 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
10 | SKIP_INSTALL = YES
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/SwiftGen/SwiftGen.release.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SwiftGen
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/SwiftGen
8 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
10 | SKIP_INSTALL = YES
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Tests/Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Example/Tests/Tests-Prefix.pch:
--------------------------------------------------------------------------------
1 | // The contents of this file are implicitly included at the beginning of every test case source file.
2 |
3 | #ifdef __OBJC__
4 |
5 |
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/Example/Tests/Tests.m:
--------------------------------------------------------------------------------
1 | //
2 | // HDTranslateModuleTests.m
3 | // HDTranslateModuleTests
4 | //
5 | // Created by denglibing on 06/19/2023.
6 | // Copyright (c) 2023 denglibing. All rights reserved.
7 | //
8 |
9 | @import XCTest;
10 |
11 | @interface Tests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation Tests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
36 |
--------------------------------------------------------------------------------
/Example/Tests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/HDTranslateModule.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod lib lint HDTranslateModule.podspec' to ensure this is a
3 | # valid spec before submitting.
4 | #
5 | # Any lines starting with a # are optional, but their use is encouraged
6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
7 | #
8 |
9 | Pod::Spec.new do |s|
10 | s.name = 'HDTranslateModule'
11 | s.version = '0.1.0'
12 | s.summary = 'iOS多语言解决方案大全:半自动化+特殊场景手动解决项目中的多语言问题'
13 |
14 | # This description is used to generate tags and improve search results.
15 | # * Think: What does it do? Why did you write it? What is the focus?
16 | # * Try to keep it short, snappy and to the point.
17 | # * Write the description between the DESC delimiters below.
18 | # * Finally, don't worry about the indent, CocoaPods strips it!
19 |
20 | s.description = <<-DESC
21 | TODO: Add long description of the pod here.
22 | DESC
23 |
24 | s.homepage = 'https://github.com/erduoniba/HDTranslateModule'
25 | s.license = { :type => 'MIT', :file => 'LICENSE' }
26 | s.author = { 'denglibing' => '328418417@qq.com' }
27 | s.source = { :git => 'git@github.com:erduoniba/HDTranslateModule.git', :tag => s.version.to_s }
28 |
29 | s.ios.deployment_target = '10.0'
30 | s.source_files = 'HDTranslateModule/Classes/**/*.{h,m,py}'
31 | s.public_header_files="HDTranslateModule/Classes**/*.h"
32 | s.resource = "HDTranslateModule/Assets/*"
33 |
34 | # s.public_header_files = 'Pod/Classes/**/*.h'
35 | # s.frameworks = 'UIKit', 'MapKit'
36 | # s.dependency 'AFNetworking', '~> 2.3'
37 | end
38 |
--------------------------------------------------------------------------------
/HDTranslateModule/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/HDTranslateModule/Assets/.gitkeep
--------------------------------------------------------------------------------
/HDTranslateModule/Assets/HDTranslateModule.bundle/en.lproj/HDTranslateModule.strings:
--------------------------------------------------------------------------------
1 | "hello" = "hello";
2 |
--------------------------------------------------------------------------------
/HDTranslateModule/Assets/HDTranslateModule.bundle/zh-Hans.lproj/HDTranslateModule.strings:
--------------------------------------------------------------------------------
1 | "hello" = "你好";
2 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/HDTranslateModule/Classes/.gitkeep
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/JDLTAttributedString.h:
--------------------------------------------------------------------------------
1 | //
2 | // JDLTAttributedString.h
3 | // JDLTTranslateModule
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface JDLTAttributedString : NSAttributedString
13 |
14 | @end
15 |
16 |
17 | @interface JDLTMutableAttributedString : NSMutableAttributedString
18 |
19 | @end
20 |
21 | NS_ASSUME_NONNULL_END
22 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/JDLTAttributedString.m:
--------------------------------------------------------------------------------
1 | //
2 | // JDLTAttributedString.m
3 | // JDLTTranslateModule
4 | //
5 | // Created by denglibing on 2023/6/19.
6 | //
7 |
8 | #import "JDLTAttributedString.h"
9 | #import "JDLTTranslateManager.h"
10 |
11 | @implementation JDLTAttributedString
12 |
13 | - (instancetype)initWithString:(NSString *)str {
14 | NSString *translateStr = [JDLTTranslateManager translateText:str];
15 | self = (JDLTAttributedString *)[[NSAttributedString alloc] initWithString:translateStr];
16 | return self;
17 | }
18 |
19 | - (instancetype)initWithString:(NSString *)str attributes:(NSDictionary *)attrs {
20 | NSString *translateStr = [JDLTTranslateManager translateText:str];
21 | self = (JDLTAttributedString *)[[NSAttributedString alloc] initWithString:translateStr attributes:attrs];
22 | return self;
23 | }
24 |
25 | @end
26 |
27 |
28 | @implementation JDLTMutableAttributedString
29 |
30 | - (instancetype)initWithString:(NSString *)str {
31 | NSString *translateStr = [JDLTTranslateManager translateText:str];
32 | self = (JDLTMutableAttributedString *)[[NSMutableAttributedString alloc] initWithString:translateStr];
33 | return self;
34 | }
35 |
36 | - (instancetype)initWithString:(NSString *)str attributes:(NSDictionary *)attrs {
37 | NSString *translateStr = [JDLTTranslateManager translateText:str];
38 | self = (JDLTMutableAttributedString *)[[NSMutableAttributedString alloc] initWithString:translateStr attributes:attrs];
39 | return self;
40 | }
41 |
42 | @end
43 |
44 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/JDLTTranslateHook.h:
--------------------------------------------------------------------------------
1 | //
2 | // JDLTTranslateHook.h
3 | // JDLTTranslateModule
4 | //
5 | // Created by denglibing on 2023/6/18.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface JDLTTranslateHook : NSObject
13 |
14 | + (void)jdltTranslateHook;
15 |
16 | @end
17 |
18 | NS_ASSUME_NONNULL_END
19 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/JDLTTranslateHook.m:
--------------------------------------------------------------------------------
1 | //
2 | // JDLTTranslateHook.m
3 | // JDLTTranslateModule
4 | //
5 | // Created by denglibing on 2023/6/18.
6 | //
7 |
8 | #import "JDLTTranslateHook.h"
9 |
10 | #import "JDLTTranslateManager.h"
11 |
12 | #import
13 |
14 |
15 |
16 | static inline void jdlttranslate_swizzleSelector(Class theClass, SEL originalSelector, SEL swizzledSelector) {
17 | Method originalMethod = class_getInstanceMethod(theClass, originalSelector);
18 | Method swizzledMethod = class_getInstanceMethod(theClass, swizzledSelector);
19 | BOOL didAddMethod = class_addMethod(theClass, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
20 | if (didAddMethod) {
21 | class_replaceMethod(theClass, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
22 | }
23 | else {
24 | if (originalMethod && swizzledMethod) {
25 | method_exchangeImplementations(originalMethod, swizzledMethod);
26 | }
27 | }
28 | }
29 |
30 |
31 | @implementation UILabel (JDLTTranslate)
32 |
33 | + (void)jdltLoad {
34 | jdlttranslate_swizzleSelector(UILabel.class, @selector(setText:), @selector(setJDLTTranslateText:));
35 | }
36 |
37 | - (void)setJDLTTranslateText:(NSString *)text {
38 | [self setJDLTTranslateText:[JDLTTranslateManager translateText:text]];
39 | }
40 |
41 | @end
42 |
43 |
44 | @implementation UITextView (JDLTTranslate)
45 |
46 | + (void)jdltLoad {
47 | jdlttranslate_swizzleSelector(UITextView.class, @selector(setText:), @selector(setJDLTTranslateText:));
48 | }
49 |
50 | - (void)setJDLTTranslateText:(NSString *)text {
51 | [self setJDLTTranslateText:[JDLTTranslateManager translateText:text]];
52 | }
53 |
54 | @end
55 |
56 |
57 | @implementation UITextField (JDLTTranslate)
58 |
59 | + (void)jdltLoad {
60 | jdlttranslate_swizzleSelector(UITextField.class, @selector(setText:), @selector(setJDLTTranslateText:));
61 | }
62 |
63 | - (void)setJDLTTranslateText:(NSString *)text {
64 | [self setJDLTTranslateText:[JDLTTranslateManager translateText:text]];
65 | }
66 |
67 | @end
68 |
69 |
70 |
71 | @implementation UITabBarItem (JDLTTranslate)
72 |
73 | + (void)jdltLoad {
74 | jdlttranslate_swizzleSelector(UITabBarItem.class, @selector(setTitle:), @selector(setJDLTTranslateTitle:));
75 | }
76 |
77 | - (void)setJDLTTranslateTitle:(NSString *)text {
78 | [self setJDLTTranslateTitle:[JDLTTranslateManager translateText:text]];
79 | }
80 |
81 | @end
82 |
83 |
84 | @implementation UINavigationItem (JDLTTranslate)
85 |
86 | + (void)jdltLoad {
87 | jdlttranslate_swizzleSelector(UINavigationItem.class, @selector(setTitle:), @selector(setJDLTTranslateTitle:));
88 | }
89 |
90 | - (void)setJDLTTranslateTitle:(NSString *)text {
91 | [self setJDLTTranslateTitle:[JDLTTranslateManager translateText:text]];
92 | }
93 |
94 | @end
95 |
96 |
97 | @implementation UIViewController (JDLTTranslate)
98 |
99 | + (void)jdltLoad {
100 | jdlttranslate_swizzleSelector(UIViewController.class, @selector(setTitle:), @selector(setJDLTTranslateTitle:));
101 | }
102 |
103 | - (void)setJDLTTranslateTitle:(NSString *)text {
104 | [self setJDLTTranslateTitle:[JDLTTranslateManager translateText:text]];
105 | }
106 |
107 | @end
108 |
109 |
110 | @implementation NSAttributedString (JDLTTranslate)
111 |
112 | + (void)jdltLoad {
113 | // 发现NSAttributedString的initWithString:和initWithString:attributes:方法确实无法直接hook。
114 | // 这可能是因为NSAttributedString的这些方法是由其子类NSConcreteAttributedString实现的。
115 | Class class = NSClassFromString(@"NSConcreteAttributedString");
116 | jdlttranslate_swizzleSelector(class, @selector(initWithString:), @selector(jdltInitWithString:));
117 | }
118 |
119 | - (instancetype)jdltInitWithString:(NSString *)str {
120 | // NSLog(@"jdltInitWithString: %@", str);
121 | return [self jdltInitWithString:[JDLTTranslateManager translateText:str]];
122 | }
123 |
124 | @end
125 |
126 |
127 |
128 | @implementation JDLTTranslateHook
129 |
130 | + (void)jdltTranslateHook {
131 | static dispatch_once_t onceToken;
132 | dispatch_once(&onceToken, ^{
133 | // UILabel:直接使用UILabel来显示文本。
134 | // UIButton:底层使用UIButtonLabel(继承自UILabel)来显示按钮标题
135 | [UILabel jdltLoad];
136 |
137 | // 底层使用NSTextContainer、NSTextStorage和NSLayoutManager等类来实现文本显示和编辑,而不是直接使用UILabel。
138 | [UITextView jdltLoad];
139 | [UITextField jdltLoad];
140 | [UITabBarItem jdltLoad];
141 | [UINavigationItem jdltLoad];
142 | [UIViewController jdltLoad];
143 |
144 | // NSMutableAttributedString 会导致偶现崩溃,不能直接book使用
145 | // 推荐使用 JDLTAttributedString、JDLTMutableAttributedString
146 | // [NSAttributedString jdltLoad];
147 | });
148 | }
149 |
150 | @end
151 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/JDLTTranslateManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // JDLTTranslateManager.h
3 | // JDLTTranslateModule
4 | //
5 | // Created by denglibing on 2023/6/18.
6 | //
7 |
8 | #import
9 |
10 |
11 | typedef NS_ENUM(NSInteger, JDLTLanguageMode) {
12 | JDLTLanguageSyetem = 0,
13 | JDLTLanguageEN,
14 | JDLTLanguageZH
15 | };
16 |
17 | NS_ASSUME_NONNULL_BEGIN
18 |
19 | @interface JDLTTranslateManager : NSObject
20 |
21 | + (instancetype)shared;
22 |
23 |
24 | /// 自定义设置本地语言包的资源路径
25 | /// - Parameters:
26 | /// - bundle: 语言包所在的bundle
27 | /// - tableName: 语言包所在的bundle的文件名称
28 | - (void)customTranslateBundle:(NSBundle *)bundle tableName:(NSString *)tableName;
29 |
30 | // 获取用户在App内选中的语言,如果用户未选中默认是System,则使用系统语言
31 | - (JDLTLanguageMode)selectedLanguage;
32 | - (void)updateLanguage:(JDLTLanguageMode)mode;
33 |
34 | // 获取用户在系统选中的语言
35 | - (JDLTLanguageMode)systemSelectedLanguage;
36 |
37 | // 根据selectedLanguage和systemSelectedLanguage最终使用到的语言,只能可能是EN和ZH
38 | // 如果用户在App选择优先使用,否则使用系统语言
39 | - (JDLTLanguageMode)realUsedLanguage;
40 |
41 |
42 | // 将 text 翻译成对应的语言
43 | + (NSString *)translateText:(NSString *)text;
44 |
45 | @end
46 |
47 | NS_ASSUME_NONNULL_END
48 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/JDLTTranslateManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // JDLTTranslateManager.m
3 | // JDLTTranslateModule
4 | //
5 | // Created by denglibing on 2023/6/18.
6 | //
7 |
8 | #import "JDLTTranslateManager.h"
9 |
10 | @interface JDLTTranslateManager ()
11 |
12 | @property (nonatomic, assign) JDLTLanguageMode selectedLanguage;
13 | @property (nonatomic, strong) NSBundle *jdltTranslateModuleBundle;
14 | @property (nonatomic, copy) NSString *lprojPath;
15 | @property (nonatomic, copy) NSString *tableName;
16 |
17 | @end
18 |
19 | @implementation JDLTTranslateManager
20 |
21 | + (instancetype)shared {
22 | static JDLTTranslateManager * instance = nil;
23 | static dispatch_once_t onceToken;
24 | dispatch_once(&onceToken, ^{
25 | instance = [[JDLTTranslateManager alloc] init];
26 | });
27 | return instance;
28 | }
29 |
30 | - (instancetype)init {
31 | self = [super init];
32 | if (self) {
33 | NSString *bundlePath = [[NSBundle bundleForClass:self.class] pathForResource:@"HDTranslateModule" ofType:@"bundle"];
34 | if (!bundlePath) {
35 | bundlePath = [[NSBundle mainBundle] pathForResource:@"HDTranslateModule" ofType:@"bundle"];
36 | }
37 | _jdltTranslateModuleBundle = [NSBundle bundleWithPath:bundlePath];
38 | _tableName = @"HDTranslateModule";
39 | _selectedLanguage = [NSUserDefaults.standardUserDefaults integerForKey:@"JDLTTranslateManager.selectedLanguage"];
40 | }
41 | return self;
42 | }
43 |
44 | - (void)customTranslateBundle:(NSBundle *)bundle tableName:(NSString *)tableName {
45 | if (bundle) {
46 | _jdltTranslateModuleBundle = bundle;
47 | [_jdltTranslateModuleBundle load];
48 | _tableName = tableName;
49 |
50 | // 切换语言模式,需要重制一次语言模型路径
51 | _lprojPath = nil;
52 | [self lprojPath];
53 | }
54 | }
55 |
56 | - (JDLTLanguageMode)selectedLanguage {
57 | return _selectedLanguage;
58 | }
59 |
60 | - (void)updateLanguage:(JDLTLanguageMode)mode {
61 | if (_selectedLanguage == mode) {
62 | return;
63 | }
64 |
65 | _selectedLanguage = mode;
66 |
67 | // 切换语言模式,需要重制一次语言模型路径
68 | _lprojPath = nil;
69 | [self lprojPath];
70 |
71 | [NSUserDefaults.standardUserDefaults setInteger:_selectedLanguage forKey:@"JDLTTranslateManager.selectedLanguage"];
72 | }
73 |
74 | - (JDLTLanguageMode)systemSelectedLanguage {
75 | //获取系统语言
76 | JDLTLanguageMode mode = JDLTLanguageEN;
77 | NSArray *languages = [NSLocale preferredLanguages];
78 | NSString *systemlanguage = [languages objectAtIndex:0];
79 | if ([systemlanguage containsString:@"zh-Hans"]) {
80 | mode = JDLTLanguageZH;
81 | }
82 | return mode;
83 | }
84 |
85 | - (JDLTLanguageMode)realUsedLanguage {
86 | if (_selectedLanguage != JDLTLanguageSyetem) {
87 | return _selectedLanguage;
88 | }
89 | return [self systemSelectedLanguage];
90 | }
91 |
92 |
93 | - (NSString *)lprojPath {
94 | if (!_lprojPath) {
95 | NSString *appLanguage = @"en";
96 | if ([JDLTTranslateManager.shared realUsedLanguage] == JDLTLanguageZH) {
97 | appLanguage = @"zh-Hans";
98 | }
99 | _lprojPath = [_jdltTranslateModuleBundle pathForResource:appLanguage ofType:@"lproj"];
100 | }
101 | return _lprojPath;
102 | }
103 |
104 |
105 | + (NSString *)translateText:(NSString *)text {
106 | NSBundle *bundle = [NSBundle bundleWithPath:JDLTTranslateManager.shared.lprojPath];
107 | NSString *tableName = JDLTTranslateManager.shared.tableName;
108 | NSString *translate = [bundle localizedStringForKey:text value:nil table:tableName];
109 | return translate;
110 | }
111 |
112 | @end
113 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/JDLTTranslateModule.h:
--------------------------------------------------------------------------------
1 | //
2 | // JDLTTranslateModule.h
3 | //
4 | //
5 | //
6 |
7 | /*
8 | 头文件中不需要暴露,或者引入任何资源
9 | */
10 |
11 | @interface JDLTTranslateModule : NSObject
12 |
13 | + (void)openAutoTranslate;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/JDLTTranslateModule.m:
--------------------------------------------------------------------------------
1 | //
2 | // JDLTTranslateModule.m
3 | //
4 | //
5 |
6 | #import
7 | #import "JDLTTranslateModule.h"
8 | #import "JDLTTranslateHook.h"
9 |
10 | @implementation JDLTTranslateModule
11 |
12 | + (void)openAutoTranslate {
13 | [JDLTTranslateHook jdltTranslateHook];
14 | }
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/HDTranslateModule_Example:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/HDTranslateModule/Classes/Python/HDTranslateModule_Example
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/HDTranslateModule_Example_cstring.txt:
--------------------------------------------------------------------------------
1 | systemlanguage: %@
2 | v16@?0q8
3 | UITableViewCell
4 | UILabelCell
5 | UIButtonCell
6 | UIButtonCell2
7 | UITextViewCell
8 | UITextViewCell2
9 | UITextFieldCell
10 | UITextFieldCell2
11 | UILable.text Case
12 | UILable.attributedText Case
13 | UIButton.setTitle Case
14 | UIButton.setAttributedTitle Case
15 | UITextView.text Case
16 | UITextView.attributedText Case
17 | UITextField.text Case
18 | UITextField.attributedText Case
19 | v32@?0@"UITabBarItem"8Q16^B24
20 | UILable.text
21 | %d
22 | %@
23 | UILable.attributedText
24 | UIButton.setTitle
25 | UIButton.setAttributedTitle
26 | UITextView.text
27 | UITextView.attributedText
28 | UITextField.text
29 | UITextField.attributedText
30 |
31 | hello
32 | Swift \37777777744\37777777670\37777777655
33 | Swift En
34 | \37777777746\37777777630\37777777657\37777777744\37777777670\37777777672 \37777777744\37777777670\37777777655
35 | Hello
36 | \37777777744\37777777675\37777777640\37777777745\37777777645\37777777675
37 | Hello \37777777744\37777777675\37777777640\37777777745\37777777645\37777777675
38 |
39 |
40 | _TtC25HDTranslateModule_Example9HDExample
41 | v16@0:8
42 | @16@0:8
43 | value
44 |
45 | \n
46 |
47 | __TEXT
48 | swift_getObjCClassMetadata
49 | _TtCs12_SwiftObject
50 | swift_getTypeContextDescriptor
51 | swift_getExistentialTypeMetadata
52 | objc_addLoadImageFunc
53 | __swift5_proto
54 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/HDTranslateModule_Example_cstring_output.json:
--------------------------------------------------------------------------------
1 | [
2 | "Swift 中",
3 | "是为 中",
4 | "你好",
5 | "Hello 你好"
6 | ]
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/HDTranslateModule_Example_cstring_output_final.json:
--------------------------------------------------------------------------------
1 | "Swift 中" = "in Swift";
2 | "是为 中" = "is for the";
3 | "你好" = "Hello";
4 | "Hello 你好" = "hello hello";
5 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/HDTranslateModule_Example_cstring_output_translate.json:
--------------------------------------------------------------------------------
1 | [
2 | "in Swift",
3 | "is for the",
4 | "Hello",
5 | "hello hello"
6 | ]
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/HDTranslateModule_Example_ustring.txt:
--------------------------------------------------------------------------------
1 | 000000010000add6 f1 82 87 65 00 00 39 5f 97 7a c4 7e f6 4e 75 98
2 | 000000010000ade6 62 97 00 00 06 52 7b 7c 13 7f 58 5b 2f 66 f6 65
3 | 000000010000adf6 f4 95 00 96 3c 50 1a ff 25 00 64 00 0c ff 53 5f
4 | 000000010000ae06 4d 52 13 7f 58 5b f6 65 f4 95 1a ff 25 00 64 00
5 | 000000010000ae16 00 00 f4 66 b0 65 44 8d 28 8d 08 54 c4 89 1a ff
6 | 000000010000ae26 25 00 40 00 00 00 11 62 2f 66 0d 67 a1 52 68 56
7 | 000000010000ae36 70 65 6e 63 00 00 2c 7b 25 00 64 00 20 5f fe 56
8 | 000000010000ae46 47 72 0d 4e 26 7b 08 54 c4 89 03 83 0c ff f7 8b
9 | 000000010000ae56 ff 66 62 63 16 62 20 52 64 96 0e 54 cd 91 b0 65
10 | 000000010000ae66 0a 4e 20 4f 00 00 a2 8b 55 53 16 7f f7 53 1a ff
11 | 000000010000ae76 25 00 40 00 00 00 2d 4e 87 65 00 00 11 62 5f 4e
12 | 000000010000ae86 2f 66 0d 67 a1 52 68 56 70 65 6e 63 00 00
13 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/HDTranslateModule_Example_ustring_output.json:
--------------------------------------------------------------------------------
1 | [
2 | "英文",
3 | "弹窗组件页面",
4 | "分类缓存是时间阀值:%d,当前缓存时间:%d"
5 | ]
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/HDTranslateModule_Example_ustring_output_final.json:
--------------------------------------------------------------------------------
1 | "英文" = "English";
2 | "弹窗组件页面" = "Pop-up component page";
3 | "分类缓存是时间阀值:%d,当前缓存时间:%d" = "Classification cache time threshold: %d, current cache time: %d";
4 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/HDTranslateModule_Example_ustring_output_translate.json:
--------------------------------------------------------------------------------
1 | [
2 | "English",
3 | "Pop-up component page",
4 | "Classification cache time threshold: %d, current cache time: %d"
5 | ]
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/find_chinese_ustrings.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import re
3 | import json
4 | import os
5 | from google.cloud import translate_v2 as translate
6 | from concurrent.futures import ThreadPoolExecutor
7 |
8 | completed_translations = 0
9 | translations = 0
10 |
11 |
12 | # 使用google进行私钥翻译:pip install google-cloud-translate
13 | def translate_text(text, src_lang='zh-CN', dest_lang='en'):
14 | translate_client = translate.Client()
15 | result = translate_client.translate(
16 | text, target_language=dest_lang, source_language=src_lang)
17 | return result['translatedText']
18 |
19 |
20 | # 翻译指令
21 | def translate_worker(value):
22 | if adjustChinese(value):
23 | translated_text = translate_text(value)
24 | if translated_text:
25 | # 使用global关键字指示我们要使用和修改全局变量
26 | global completed_translations
27 | global translations
28 |
29 | completed_translations += 1
30 | # print(value+"翻译成功")
31 | print("翻译进度:", completed_translations, "/", translations)
32 | return (value, translated_text)
33 | else:
34 | print(value+"翻译失败")
35 | return None
36 |
37 |
38 | # 十六进制转成中文,并且中英文翻译
39 | def otool_hex_to_str(otool_output):
40 | # 提取十六进制数据
41 | hex_data = re.findall(r'\t([0-9a-fA-F ]+)', otool_output)
42 | # print("hex_data", hex_data)
43 |
44 | # 将十六进制数据连接成一个字符串
45 | hex_str = ''.join(hex_data).replace(' ', '')
46 | # print("hex_str", hex_str)
47 |
48 | # 将十六进制数据转换为字节串
49 | byte_data = bytes.fromhex(hex_str)
50 | # print("byte_data", byte_data)
51 |
52 | # 尝试以UTF-16编码解码字节串
53 | decoded_str = byte_data.decode('utf-16', errors='ignore')
54 | # print("decoded_str", decoded_str)
55 |
56 | # 使用正则表达式匹配所有非空字符
57 | all_strings = re.findall(r'[^\x00]+', decoded_str)
58 | # print("all_strings", all_strings)
59 |
60 | # all_strings可能有非中文,请过滤掉
61 | output_datas = []
62 | output_translate_datas = []
63 | total_texts = len(all_strings)
64 |
65 | global translations
66 | translations = len(all_strings)
67 |
68 | # 这个修改后的代码使用了ThreadPoolExecutor来实现多线程翻译。translate_worker函数是一个新的辅助函数,
69 | # 它接受一个字符串并尝试翻译。otool_hex_to_str函数中的循环被替换为一个executor.map调用,
70 | # 它将translate_worker应用于all_strings中的每个元素。这将并行执行翻译任务,从而加快速度。
71 | with ThreadPoolExecutor() as executor:
72 | results = list(executor.map(translate_worker, all_strings))
73 |
74 | for result in results:
75 | if result is not None:
76 | output_datas.append(result[0])
77 | output_translate_datas.append(result[1])
78 |
79 | return output_datas, output_translate_datas
80 |
81 |
82 | # 判断是否包含中文
83 | def adjustChinese(value):
84 | if value:
85 | if len(value) > 0:
86 | for s in value:
87 | if u'\u4e00' <= s <= u'\u9fff':
88 | return True
89 | return False
90 |
91 |
92 | # 将otool命令输出的内容写入文件
93 | def otool_to_file(macho_file, ustring_file):
94 | # 将otool命令输出的内容写入文件
95 | os.system(f"otool -X -s __TEXT __ustring {macho_file} > {ustring_file}")
96 |
97 |
98 | # 读取ustring_file文件,并将其json数组,然后翻译,返回原始数据和翻译后数据
99 | def read_ustring_file(ustring_file):
100 | with open(ustring_file, 'r') as f:
101 | otool_output = f.read()
102 | return otool_hex_to_str(otool_output)
103 |
104 |
105 | # 将翻译后的all_strings、all_translate_strings写入file_path、file_translate_path文件
106 | def write_ustring_local_file(file_path, file_translate_path, all_strings, all_translate_strings):
107 | with open(file_path, 'w', encoding='utf-8') as f:
108 | json.dump(all_strings, f, ensure_ascii=False, indent=2)
109 | with open(file_translate_path, 'w', encoding='utf-8') as f:
110 | json.dump(all_translate_strings, f, ensure_ascii=False, indent=2)
111 |
112 |
113 | # 读取file_path、file_translate_path文件,并将其json数组以 如下格式写入ustring_output.json文件
114 | def read_ustring_local_file(file_path, file_translate_path):
115 | with open(file_path, 'r', encoding='utf-8') as f:
116 | file_path_data = json.load(f)
117 | with open(file_translate_path, 'r', encoding='utf-8') as f:
118 | file_translate_path_data = json.load(f)
119 | return file_path_data, file_translate_path_data
120 |
121 |
122 | # 将all_strings、all_translate_strings 以 "中文"="English" 的形式写入file_final_path.json文件
123 | def write_final_ustring_local_file(file_final_path, all_strings, all_translate_strings):
124 | with open(file_final_path, 'w', encoding='utf-8') as f:
125 | for index in range(len(all_strings)):
126 | # 使用原始字符串表示法,repr(),以便在all_translate_strings中的\n不被转义
127 | # 使用了repr()函数来获取all_strings[index]和all_translate_strings[index]的可打印表示。
128 | # 这将确保\n不被转义。但是,repr()函数还会在字符串的开头和结尾添加额外的单引号。
129 | # 为了避免这个问题,您可以在format()函数中使用切片操作来去掉这些额外的单引号。
130 | f.write(r'"{}" = "{}";'.format(
131 | repr(all_strings[index])[1:-1], repr(all_translate_strings[index])[1:-1]) + '\n')
132 |
133 |
134 | # python3 find_chinese_utrings.py HDFindStringDemo
135 | if __name__ == '__main__':
136 | print("start")
137 |
138 | macho_file = sys.argv[1]
139 | ustring_file = f"{macho_file}_ustring.txt"
140 | output_file = f"{macho_file}_ustring_output.json"
141 | file_translate_path = f"{macho_file}_ustring_output_translate.json"
142 | file_final_path = f"{macho_file}_ustring_output_final.json"
143 |
144 | ########## 翻译+读写全流程 ##########
145 | # 翻译+读写全流程step1:将otool命令输出的内容写入文件
146 | otool_to_file(macho_file, ustring_file)
147 |
148 | # # 翻译+读写全流程step2:读取ustring_file文件,并将其json数组,然后翻译,返回原始数据和翻译后数据
149 | all_strings, all_translate_strings = read_ustring_file(ustring_file)
150 |
151 | # # 翻译+读写全流程step3:将翻译后的all_strings、all_translate_strings写入output_file、file_translate_path文件
152 | write_ustring_local_file(
153 | output_file, file_translate_path, all_strings, all_translate_strings)
154 |
155 | # # 翻译+读写全流程step4:将all_strings、all_translate_strings 以 "中文"="English" 的形式写入file_final_path.json文件
156 | write_final_ustring_local_file(
157 | file_final_path, all_strings, all_translate_strings)
158 | ########## 翻译+读写全流程 ##########
159 |
160 | ########## 本地文件读取翻译 ##########
161 | # 本地文件读取step1 读取output_file、file_translate_path文件,并将其json数组以 如下格式写入ustring_output.json文件
162 | # all_strings, all_translate_strings = read_ustring_local_file(
163 | # output_file, file_translate_path)
164 |
165 | # 本地文件读取step2:将all_strings、all_translate_strings 以 "中文"="English" 的形式写入file_final_path.json文件
166 | # write_final_ustring_local_file(
167 | # file_final_path, all_strings, all_translate_strings)
168 | ########## 本地文件读取翻译 ##########
169 |
170 | print("end")
171 |
--------------------------------------------------------------------------------
/HDTranslateModule/Classes/Python/translate_strings.py:
--------------------------------------------------------------------------------
1 | import xml.etree.ElementTree as ET
2 | import subprocess
3 |
4 | # xml 转成 原始的 .strings 文件
5 | def convert_plist_to_strings(plist_path, strings_path):
6 | # 解析XML文件
7 | tree = ET.parse(plist_path)
8 | root = tree.getroot()
9 |
10 | # 打开一个新的.strings文件用于写入
11 | with open(strings_path, 'w', encoding='utf-8') as strings_file:
12 | # plist文件的结构通常包含一个顶层的元素
13 | dict_elements = root.findall('dict')
14 | for dict_element in dict_elements:
15 | # 遍历dict内的元素
16 | elements = list(dict_element)
17 | for i, element in enumerate(elements):
18 | if element.tag == 'key':
19 | key_text = element.text
20 | # 获取与key相邻的下一个string元素
21 | if i+1 < len(elements) and elements[i+1].tag == 'string':
22 | value_text = elements[i+1].text
23 | # 写入转换后的键值对到.strings文件
24 | strings_file.write(f'"{key_text}" = "{value_text}";\n')
25 |
26 | def covert_strings_to_plist(strings_path, plist_path):
27 | # 使用 f-string 格式化命令
28 | command = f"plutil -convert xml1 {strings_path} -o {plist_path}"
29 |
30 | # 执行命令
31 | subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
32 |
33 | # 调用函数进行转换
34 | covert_strings_to_plist('mm.strings', 'mm.xml')
35 | convert_plist_to_strings('mm.xml', 'mmOrigin.strings')
36 |
37 | print('转换完成。')
38 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2023 denglibing <328418417@qq.com>
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/SwiftgemStringsOutput/Strings+Generated.swift:
--------------------------------------------------------------------------------
1 | // swiftlint:disable all
2 | // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3 |
4 | import Foundation
5 |
6 | // swiftlint:disable superfluous_disable_command file_length implicit_return prefer_self_in_static_references
7 |
8 | // MARK: - Strings
9 |
10 | // swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
11 | // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
12 | internal enum L10n {
13 | internal enum InfoPlist {
14 | /// HDTranslate
15 | internal static let cfBundleDisplayName = L10n.tr("InfoPlist", "CFBundleDisplayName", fallback: "HDTranslate")
16 | /// Needs access to your camera to take you to experience code scanning, shooting, red envelope scanning, reality shopping, etc
17 | internal static let nsPhotoLibraryUsageDescription = L10n.tr("InfoPlist", "NSPhotoLibraryUsageDescription", fallback: "Needs access to your camera to take you to experience code scanning, shooting, red envelope scanning, reality shopping, etc")
18 | }
19 | internal enum LaunchScreen {
20 | internal enum Ev1CzGJn {
21 | /// I am English LaunchScreen
22 | internal static let text = L10n.tr("LaunchScreen", "Ev1-cz-gJn.text", fallback: "I am English LaunchScreen")
23 | }
24 | }
25 | internal enum Localizabless {
26 | /// good
27 | internal static let good = L10n.tr("Localizabless", "good", fallback: "good")
28 | /// Localizable.strings
29 | /// HDTranslateModule
30 | ///
31 | /// Created by denglibing on 2023/8/16.
32 | /// Copyright © 2023 denglibing5. All rights reserved.
33 | internal static let hello = L10n.tr("Localizabless", "hello", fallback: "hello")
34 | }
35 | }
36 | // swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length
37 | // swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
38 |
39 | // MARK: - Implementation Details
40 |
41 | extension L10n {
42 | private static func tr(_ table: String, _ key: String, _ args: CVarArg..., fallback value: String) -> String {
43 | let format = BundleToken.bundle.localizedString(forKey: key, value: value, table: table)
44 | return String(format: format, locale: Locale.current, arguments: args)
45 | }
46 | }
47 |
48 | // swiftlint:disable convenience_type
49 | private final class BundleToken {
50 | static let bundle: Bundle = {
51 | #if SWIFT_PACKAGE
52 | return Bundle.module
53 | #else
54 | return Bundle(for: BundleToken.self)
55 | #endif
56 | }()
57 | }
58 | // swiftlint:enable convenience_type
59 |
--------------------------------------------------------------------------------
/_Pods.xcodeproj:
--------------------------------------------------------------------------------
1 | Example/Pods/Pods.xcodeproj
--------------------------------------------------------------------------------
/en.lproj/Localizable.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/en.lproj/Localizable.strings
--------------------------------------------------------------------------------
/swiftgen.yml:
--------------------------------------------------------------------------------
1 | ## Note: all of the config entries below are just examples with placeholders. Be sure to edit and adjust to your needs when uncommenting.
2 |
3 | ## In case your config entries all use a common input/output parent directory, you can specify those here.
4 | ## Every input/output paths in the rest of the config will then be expressed relative to these.
5 | ## Those two top-level keys are optional and default to "." (the directory of the config file).
6 | # input_dir: HDTranslateModule/Assets/
7 | input_dir: Example/HDTranslateModule/
8 | # output_dir: SwiftgemStringsOutput/
9 |
10 |
11 | # Generate constants for your localized strings.
12 | # Be sure that SwiftGen only parses ONE locale (typically Base.lproj, or en.lproj, or whichever your development region is); otherwise it will generate the same keys multiple times.
13 | # SwiftGen will parse all `.strings` files found in that folder.
14 | strings:
15 | inputs:
16 | - en.lproj
17 | - zh-Hans.lproj
18 | outputs:
19 | - templateName: structured-swift5
20 | output: SwiftgemStringsOutput/Strings+Generated.swift
21 |
22 |
23 | ## Generate constants for your Assets Catalogs, including constants for images, colors, ARKit resources, etc.
24 | ## This example also shows how to provide additional parameters to your template to customize the output.
25 | ## - Especially the `forceProvidesNamespaces: true` param forces to create sub-namespace for each folder/group used in your Asset Catalogs, even the ones without "Provides Namespace". Without this param, SwiftGen only generates sub-namespaces for folders/groups which have the "Provides Namespace" box checked in the Inspector pane.
26 | ## - To know which params are supported for a template, use `swiftgen template doc xcassets swift5` to open the template documentation on GitHub.
27 | # xcassets:
28 | # inputs:
29 | # - Main.xcassets
30 | # - ProFeatures.xcassets
31 | # outputs:
32 | # - templateName: swift5
33 | # params:
34 | # forceProvidesNamespaces: true
35 | # output: XCAssets+Generated.swift
36 |
37 |
38 | ## Generate constants for your storyboards and XIBs.
39 | ## This one generates 2 output files, one containing the storyboard scenes, and another for the segues.
40 | ## (You can remove the segues entry if you don't use segues in your IB files).
41 | ## For `inputs` we can use "." here (aka "current directory", at least relative to `input_dir` = "MyLib/Sources"),
42 | ## and SwiftGen will recursively find all `*.storyboard` and `*.xib` files in there.
43 | # ib:
44 | # inputs:
45 | # - .
46 | # outputs:
47 | # - templateName: scenes-swift5
48 | # output: IB-Scenes+Generated.swift
49 | # - templateName: segues-swift5
50 | # output: IB-Segues+Generated.swift
51 |
52 |
53 | ## There are other parsers available for you to use depending on your needs, for example:
54 | ## - `fonts` (if you have custom ttf/ttc font files)
55 | ## - `coredata` (for CoreData models)
56 | ## - `json`, `yaml` and `plist` (to parse custom JSON/YAML/Plist files and generate code from their content)
57 | ## …
58 | ##
59 | ## For more info, use `swiftgen config doc` to open the full documentation on GitHub.
60 | ## https://github.com/SwiftGen/SwiftGen/tree/6.6.2/Documentation/
61 |
--------------------------------------------------------------------------------
/temp.lproj/Localizable.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/erduoniba/HDTranslateModule/033769063e96543caaa9d7709539dda0109f5971/temp.lproj/Localizable.strings
--------------------------------------------------------------------------------