30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/fastlane/plugin/translate_gpt/actions/translate_gpt_action.rb', line 30
def self.available_options
[
FastlaneCore::ConfigItem.new(
key: :api_token,
env_name: "GPT_API_KEY",
description: "API token for ChatGPT",
sensitive: true,
code_gen_sensitive: true,
default_value: ""
),
FastlaneCore::ConfigItem.new(
key: :model_name,
env_name: "GPT_MODEL_NAME",
description: "Name of the ChatGPT model to use",
default_value: "gpt-3.5-turbo"
),
FastlaneCore::ConfigItem.new(
key: :request_timeout,
env_name: "GPT_REQUEST_TIMEOUT",
description: "Timeout for the request in seconds",
type: Integer,
default_value: 30
),
FastlaneCore::ConfigItem.new(
key: :temperature,
env_name: "GPT_TEMPERATURE",
description: "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic",
type: Float,
optional: true,
default_value: 0.5
),
FastlaneCore::ConfigItem.new(
key: :skip_translated,
env_name: "GPT_SKIP_TRANSLATED",
description: "Whether to skip strings that have already been translated",
type: Boolean,
optional: true,
default_value: true
),
FastlaneCore::ConfigItem.new(
key: :source_language,
env_name: "GPT_SOURCE_LANGUAGE",
description: "Source language to translate from",
default_value: "auto"
),
FastlaneCore::ConfigItem.new(
key: :target_language,
env_name: "GPT_TARGET_LANGUAGE",
description: "Target language to translate to",
default_value: "en"
),
FastlaneCore::ConfigItem.new(
key: :source_file,
env_name: "GPT_SOURCE_FILE",
description: "The path to the Localizable.strings file to be translated",
verify_block: proc do |value|
UI.user_error!("Invalid file path: #{value}") unless File.exist?(value)
extension = File.extname(value)
available_extensions = [".strings", ".xcstrings"]
UI.user_error!("Translation file must have any of these extensions: #{available_extensions}") unless available_extensions.include? extension
end
),
FastlaneCore::ConfigItem.new(
key: :target_file,
env_name: "GPT_TARGET_FILE",
description: "Path to the translation file to update",
verify_block: proc do |value|
UI.user_error!("Invalid file path: #{value}") unless File.exist?(value)
extension = File.extname(value)
available_extensions = [".strings", ".xcstrings"]
UI.user_error!("Translation file must have any of these extensions: #{available_extensions}") unless available_extensions.include? extension
end
),
FastlaneCore::ConfigItem.new(
key: :context,
env_name: "GPT_COMMON_CONTEXT",
description: "Common context for the translation",
optional: true,
type: String
),
FastlaneCore::ConfigItem.new(
key: :bunch_size,
env_name: "GPT_BUNCH_SIZE",
description: "Number of strings to translate in a single request",
optional: true,
type: Integer
),
]
end
|