-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.cfm
More file actions
executable file
·181 lines (147 loc) · 6.29 KB
/
index.cfm
File metadata and controls
executable file
·181 lines (147 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<style>
body {font-family: "Segoe UI", Arial, sans-serif; line-height: 1.7; color: #222; background: #fdfdfd;}
h1, h3, h4 {color: #1976d2;}
h1 {font-size: 36px; border-bottom: 4px solid #eee; padding-bottom: 15px;}
h2 {color: #333; border-bottom: 2px solid #2196F3; padding-bottom: 8px;}
code {background: #f0f7ff; padding: 3px 8px; border-radius: 4px; font-size: 92%; color: #d63384;}
pre {background: #f8f9fa; padding: 16px; border-radius: 8px; overflow-x: auto; border: 1px solid #e0e0e0; font-size: 14px;}
.highlight {background: #e8f5e8; padding: 16px; border-left: 5px solid #4caf50; border-radius: 0 8px 8px 0; margin: 20px 0;}
.pro {background: #fff8e1; padding: 16px; border-left: 5px solid #ff9800; border-radius: 0 8px 8px 0; margin: 25px 0;}
.note {background: #e3f2fd; padding: 14px; border-left: 4px solid #1976d2; margin: 20px 0; border-radius: 4px;}
table {width: 100%; border-collapse: collapse; margin: 20px 0;}
th, td {padding: 12px; border: 1px solid #ddd; text-align: left;}
th {background: #f5f5f5;}
hr {border: none; height: 1px; background: #ddd; margin: 20px 0;}
ul {padding-left: 20px;}
a {color: #1976d2; text-decoration: none;}
a:hover {text-decoration: underline;}
</style>
<h1>Wheels Internationalization Plugin via Google Translator</h1>
<p><strong>Runtime page & HTML translation plugin for Wheels using Google Translate API.</strong></p>
<hr>
<h2>Why wheels-googleTranslator?</h2>
<ul>
<li>No database or JSON files required</li>
<li>Translates full HTML pages safely</li>
<li>Preserves markup & structure</li>
<li>Session-based language switching</li>
<li>Optional in-memory caching</li>
</ul>
<div class="note">
<strong>Use case:</strong> Perfect when you need instant multilingual pages without managing translation files.
</div>
<hr>
<h2>Installation</h2>
<pre>wheels plugin install wheels-googleTranslator</pre>
<hr>
<h2>Configuration</h2>
<p>Add these settings to <code>config/settings.cfm</code>:</p>
<pre>
set(gt_defaultLanguage="en");
set(gt_availableLanguages="en,es,fr");
set(gt_apiKey="YOUR_GOOGLE_API_KEY");
set(gt_cacheEnabled=false);
</pre>
<p>To obtain a Google Cloud Translation API key, follow the official setup guide: <a href="https://cloud.google.com/translate/docs/setup" target="_blank">https://cloud.google.com/translate/docs/setup</a></p>
<div class="note">
<strong>Note:</strong> You will need a Google Cloud project with billing enabled. New users get free credits to start.
</div>
<p>Below is a description of all available configuration settings and their default values:</p>
<table>
<thead>
<tr>
<th>Setting Name</th>
<th>Default Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>gt_defaultLanguage</strong></td>
<td><code>"en"</code></td>
<td>The default language (language code) to use if no session language is set.</td>
</tr>
<tr>
<td><strong>gt_availableLanguages</strong></td>
<td><code>"en"</code></td>
<td>A comma-separated list of all supported languages (e.g., <code>"en,es,fr"</code>).</td>
</tr>
<tr>
<td><strong>gt_apiKey</strong></td>
<td><code>empty</code></td>
<td>Google Translation API Key for your application translations.</td>
</tr>
<tr>
<td><strong>gt_cacheEnabled</strong></td>
<td><code>false</code></td>
<td>Set true to cache translations in memory (recommended for production).</td>
</tr>
</tbody>
</table>
<div class="note">
<strong>Pro Tip:</strong> Set <code>gt_cacheEnabled=true</code> in production for fast performance.
</div>
<hr>
<h2>Plugin Functions</h2>
<ul>
<li><code>#whlsGt("text", "language", "format")#</code> → Translate Single Text</li>
<li><code>#whlsGtTranslate("text", "language")#</code> → Translate Full Page</li>
<li><code>#whlsChangeLanguage("es")#</code> → Switch language</li>
<li><code>#whlsCurrentLanguage()#</code> → Get current language</li>
<li><code>#whlsAvailableLanguages()#</code> → Array of supported languages</li>
</ul>
<hr>
<h3>Usage: Key Functions</h3>
<h4>Translate Single Text - <code>whlsGt()</code></h4>
<p>The core function to translate a single text to the destination language, with parameter interpolation and fallback logic.</p>
<pre>
// Basic Usage
#whlsGt("Welcome to the application", "es", "text")# // (Output: Bienvenido a la aplicación)
// With parameter interpolation
#whlsGt("Hello, Mr John Doe!", "fr", "text")# // (Output: "Bonjour, Monsieur John Doe!")
</pre>
<h4>Translate Full HTML Content – <code>whlsGtTranslate()</code></h4>
<p>
Translates a full HTML block or page while <strong>preserving the original markup</strong>.
Only readable text nodes are sent to the translation provider, ensuring that
HTML tags, attributes, and structure remain untouched.
</p>
<p>
This function is ideal for translating:
</p>
<pre>
// Translate full HTML content
#whlsGtTranslate(includeContent(), "es")#
// Translate a raw HTML string
#whlsGtTranslate(
text = "<h1>Hello World</h1><p>Welcome to our site</p>",
target = "fr"
)#
</pre>
<div class="highlight">
<strong>Tip:</strong> Wrap your full page output with <code>whlsGtTranslate()</code> to translate everything at once.
</div>
<h4>Current Language - <code>whlsCurrentLanguage()</code></h4>
<p>Gets the current application language from the Session, or the default language if not set.</p>
<pre>
language = whlsCurrentLanguage(); // "en"
</pre>
<h4>Change Language - <code>whlsChangeLanguage()</code></h4>
<p>Sets the application language in Session and returns a boolean based on success.</p>
<pre>
// Change to Spanish
whlsChangeLanguage("es");
// Unsupported language
whlsChangeLanguage("jp"); // false
</pre>
<h4>Available Languages - <code>whlsAvailableLanguages()</code></h4>
<p>Returns an array of all configured available languages.</p>
<pre>
languages = whlsAvailableLanguages(); // ["en", "es", "fr"]
</pre>
<hr>
<div class="highlight">
Made with love by <strong>wheels-dev</strong><br>
MIT License • Works with Wheels 3.0+<br>
GitHub: <a href="https://github.com/wheels-dev/wheels-i18n-gt">github.com/wheels-dev/wheels-i18n-gt</a>
</div>