Version Description
This version allows sorting of languages within the widget
=
Download this release
Release Info
Developer | oferwald |
Plugin | Transposh WordPress Translation |
Version | 0.3.9 |
Comparing to | |
See all releases |
Code changes from version 0.3.8 to 0.3.9
- core/constants.php +249 -56
- css/transposh_widget.css +1 -1
- img/bingicon.png +0 -0
- img/googleicon.png +0 -0
- img/rtlicon.png +0 -0
- js/transposhcontrol.js +1 -0
- readme.txt +56 -27
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- transposh.php +16 -43
- transposh_admin.php → wp/transposh_admin.php +137 -126
- wp/transposh_ajax.php +52 -0
- transposh_db.php → wp/transposh_db.php +0 -4
- transposh_options.php → wp/transposh_options.php +28 -13
- transposh_postpublish.php → wp/transposh_postpublish.php +0 -3
- transposh_widget.php → wp/transposh_widget.php +5 -10
core/constants.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the Free Software
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
-
|
18 |
|
19 |
//Language indicator in URL. i.e. lang=en
|
20 |
define("LANG_PARAM", "lang");
|
@@ -29,69 +29,74 @@ define("ENABLE_APC", TRUE);
|
|
29 |
define("NO_TRANSLATE_CLASS", "no_translate");
|
30 |
|
31 |
//Supported languages, new languages can be added here
|
32 |
-
//the array directs from language code to - Native name, flag
|
33 |
$languages = array(
|
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 |
//Language which are read from right to left (rtl)
|
89 |
-
$rtl_languages =
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
//Define the new capability that will be assigned to roles - translator
|
92 |
define("TRANSLATOR", 'translator');
|
93 |
|
94 |
-
define("TRANSPOSH_PLUGIN_VER",'0.3.
|
95 |
|
96 |
//Define segment id prefix, will be included in span tag. also used as class identifier
|
97 |
define("SPAN_PREFIX", "tr_");
|
@@ -102,4 +107,192 @@ define('TRANSPOSH_ADMIN_PAGE_NAME', 'transposh');
|
|
102 |
//0.3.5 - Storing all options in this config option
|
103 |
define("TRANSPOSH_OPTIONS", "transposh_options");
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
?>
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the Free Software
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
+
*/
|
18 |
|
19 |
//Language indicator in URL. i.e. lang=en
|
20 |
define("LANG_PARAM", "lang");
|
29 |
define("NO_TRANSLATE_CLASS", "no_translate");
|
30 |
|
31 |
//Supported languages, new languages can be added here
|
32 |
+
//the array directs from language code to - English Name, Native name, flag
|
33 |
$languages = array(
|
34 |
+
"en" => "English,English,us",
|
35 |
+
"af" => "Afrikaans,Afrikaans,za",
|
36 |
+
"sq" => "Albanian,Shqip,al",
|
37 |
+
"ar" => "Arabic,العربية,sa",
|
38 |
+
"be" => "Belarusian,Беларуская,by",
|
39 |
+
"bg" => "Bulgarian,Български,bg",
|
40 |
+
"ca" => "Catalan,Català,catalonia",
|
41 |
+
"zh" => "Chinese (Simplified),中文(简体),cn",
|
42 |
+
"zh-tw" => "Chinese (Traditional),中文(漢字),tw",
|
43 |
+
"hr" => "Croatian,Hrvatski,hr",
|
44 |
+
"cs" => "Czech,čeština,cz",
|
45 |
+
"da" => "Danish,dansk,dk",
|
46 |
+
"nl" => "Dutch,Nederlands,nl",
|
47 |
+
"et" => "Estonian,Eesti keel,ee",
|
48 |
+
"fi" => "Finnish,Suomi,fi",
|
49 |
+
"fr" => "French,Français,fr",
|
50 |
+
"gl" => "Galician,Galego,galicia",
|
51 |
+
"de" => "German,Deutsch,de",
|
52 |
+
"el" => "Greek,Ελληνικά,gr",
|
53 |
+
"he" => "Hebrew,עברית,il",
|
54 |
+
"hi" => "Hindi,हिन्दी; हिंदी,in",
|
55 |
+
"hu" => "Hungarian,magyar,hu",
|
56 |
+
"id" => "Indonesian,Bahasa Indonesia,id",
|
57 |
+
"it" => "Italian,Italiano,it",
|
58 |
+
"is" => "Icelandic,íslenska,is",
|
59 |
+
"ga" => "Irish,Gaeilge,ie",
|
60 |
+
"ja" => "Japanese,日本語,jp",
|
61 |
+
"ko" => "Korean,우리말,kr",
|
62 |
+
"lv" => "Latvian,latviešu valoda,lv",
|
63 |
+
"lt" => "Lithuanian,lietuvių kalba,lt",
|
64 |
+
"mk" => "Macedonian,македонски јазик,mk",
|
65 |
+
"ms" => "Malay,bahasa Melayu,my",
|
66 |
+
"mt" => "Maltese,Malti,mt",
|
67 |
+
"no" => "Norwegian,Norsk,no",
|
68 |
+
"fa" => "Persian,فارسی,ir",
|
69 |
+
"pl" => "Polish,Polski,pl",
|
70 |
+
"pt" => "Portuguese,Português,pt",
|
71 |
+
"ro" => "Romanian,Română,ro",
|
72 |
+
"ru" => "Russian,Русский,ru",
|
73 |
+
"sr" => "Serbian,српски језик,rs",
|
74 |
+
"sk" => "Slovak,slovenčina,sk",
|
75 |
+
"sl" => "Slovene,slovenščina,sl",
|
76 |
+
"es" => "Spanish,Español,es",
|
77 |
+
"sw" => "Swahili,Kiswahili,ke",
|
78 |
+
"sv" => "Swedish,svenska,se",
|
79 |
+
"tl" => "Tagalog,Tagalog,ph",
|
80 |
+
"th" => "Thai,ภาษาไทย,th",
|
81 |
+
"tr" => "Turkish,Türkçe,tr",
|
82 |
+
"uk" => "Ukrainian,Українська,ua",
|
83 |
+
"vi" => "Vietnamese,Tiếng Việt,vn",
|
84 |
+
"cy" => "Welsh,Cymraeg,wales",
|
85 |
+
"yi" => "Yiddish,ייִדיש,europeanunion"
|
86 |
);
|
87 |
|
88 |
//Language which are read from right to left (rtl)
|
89 |
+
$rtl_languages = array("ar", "he", "fa", "yi");
|
90 |
+
|
91 |
+
//Google supported languages @updated 2009-Dec-21
|
92 |
+
$google_languages = array("en", "af", "sq", "ar", "be", "bg", "ca", "zh", "zh-tw", "hr", "cs", "da", "nl", "et", "fi", "fr", "gl", "de", "el", "he", "hi", "hu", "id", "it", "is", "ga", "ja", "ko", "lv", "lt", "mk", "ms", "mt", "no", "fa", "pl", "pt", "ro", "ru", "sr", "sk", "sl", "es", "sw", "sv", "tl", "th", "tr", "uk", "vi", "cy", "yi");
|
93 |
+
//Bing supported languages @updated 2009-Dec-21
|
94 |
+
$bing_languages = array("en", "ar", "bg", "zh", "zh-tw", "cs", "da", "nl", "fi", "fr", "de", "gr", "he", "it", "ja", "ko", "pl", "pt", "ru", "es", "sv", "th");
|
95 |
|
96 |
//Define the new capability that will be assigned to roles - translator
|
97 |
define("TRANSLATOR", 'translator');
|
98 |
|
99 |
+
define("TRANSPOSH_PLUGIN_VER",'0.3.9');
|
100 |
|
101 |
//Define segment id prefix, will be included in span tag. also used as class identifier
|
102 |
define("SPAN_PREFIX", "tr_");
|
107 |
//0.3.5 - Storing all options in this config option
|
108 |
define("TRANSPOSH_OPTIONS", "transposh_options");
|
109 |
|
110 |
+
/* Full language list according to ISO
|
111 |
+
ISO 639-1 Language name Native name
|
112 |
+
aa Afar Afaraf
|
113 |
+
ab Abkhazian Аҧсуа
|
114 |
+
ae Avestan avesta
|
115 |
+
af Afrikaans Afrikaans
|
116 |
+
ak Akan Akan
|
117 |
+
am Amharic አማርኛ
|
118 |
+
an Aragonese Aragonés
|
119 |
+
ar Arabic العربية
|
120 |
+
as Assamese অসমীয়া
|
121 |
+
av Avaric авар мацӀ, магӀарул мацӀ
|
122 |
+
ay Aymara aymar aru
|
123 |
+
az Azerbaijani azərbaycan dili
|
124 |
+
ba Bashkir башҡорт теле
|
125 |
+
be Belarusian Беларуская
|
126 |
+
bg Bulgarian български език
|
127 |
+
bh Bihari भोजपुरी
|
128 |
+
bi Bislama Bislama
|
129 |
+
bm Bambara bamanankan
|
130 |
+
bn Bengali বাংলা
|
131 |
+
bo Tibetan བོད་ཡིག
|
132 |
+
br Breton brezhoneg
|
133 |
+
bs Bosnian bosanski jezik
|
134 |
+
ca Catalan, Valencian Català
|
135 |
+
ce Chechen нохчийн мотт
|
136 |
+
ch Chamorro Chamoru
|
137 |
+
co Corsican corsu, lingua corsa
|
138 |
+
cr Cree ᓀᐦᐃᔭᐍᐏᐣ
|
139 |
+
cs Czech česky, čeština
|
140 |
+
cu Church Slavic, Old Slavonic, Church Slavonic, Old Bulgarian, Old Church Slavonic ѩзыкъ словѣньскъ
|
141 |
+
cv Chuvash чӑваш чӗлхи
|
142 |
+
cy Welsh Cymraeg
|
143 |
+
da Danish dansk
|
144 |
+
de German Deutsch
|
145 |
+
dv Divehi, Dhivehi, Maldivian ދިވެހި
|
146 |
+
dz Dzongkha རྫོང་ཁ
|
147 |
+
ee Ewe Eʋegbe
|
148 |
+
el Modern Greek Ελληνικά
|
149 |
+
en English English
|
150 |
+
eo Esperanto Esperanto
|
151 |
+
es Spanish, Castilian español, castellano
|
152 |
+
et Estonian eesti, eesti keel
|
153 |
+
eu Basque euskara, euskera
|
154 |
+
fa Persian فارسی
|
155 |
+
ff Fulah Fulfulde, Pulaar, Pular
|
156 |
+
fi Finnish suomi, suomen kieli
|
157 |
+
fj Fijian vosa Vakaviti
|
158 |
+
fo Faroese føroyskt
|
159 |
+
fr French français, langue française
|
160 |
+
fy Western Frisian Frysk
|
161 |
+
ga Irish Gaeilge
|
162 |
+
gd Gaelic, Scottish Gaelic Gàidhlig
|
163 |
+
gl Galician Galego
|
164 |
+
gn Guaraní Avañe'ẽ
|
165 |
+
gu Gujarati ગુજરાતી
|
166 |
+
gv Manx Gaelg, Gailck
|
167 |
+
ha Hausa Hausa, هَوُسَ
|
168 |
+
he Modern Hebrew עברית
|
169 |
+
hi Hindi हिन्दी, हिंदी
|
170 |
+
ho Hiri Motu Hiri Motu
|
171 |
+
hr Croatian hrvatski
|
172 |
+
ht Haitian, Haitian Creole Kreyòl ayisyen
|
173 |
+
hu Hungarian Magyar
|
174 |
+
hy Armenian Հայերեն
|
175 |
+
hz Herero Otjiherero
|
176 |
+
ia Interlingua (International Auxiliary Language Association) Interlingua
|
177 |
+
id Indonesian Bahasa Indonesia
|
178 |
+
ie Interlingue, Occidental Interlingue
|
179 |
+
ig Igbo Igbo
|
180 |
+
ii Sichuan Yi, Nuosu ꆇꉙ
|
181 |
+
ik Inupiaq Iñupiaq, Iñupiatun
|
182 |
+
io Ido Ido
|
183 |
+
is Icelandic Íslenska
|
184 |
+
it Italian Italiano
|
185 |
+
iu Inuktitut ᐃᓄᒃᑎᑐᑦ
|
186 |
+
ja Japanese 日本語 (にほんご/にっぽんご)
|
187 |
+
jv Javanese basa Jawa
|
188 |
+
ka Georgian ქართული
|
189 |
+
kg Kongo KiKongo
|
190 |
+
ki Kikuyu, Gikuyu Gĩkũyũ
|
191 |
+
kj Kwanyama, Kuanyama Kuanyama
|
192 |
+
kk Kazakh Қазақ тілі
|
193 |
+
kl Kalaallisut, Greenlandic kalaallisut, kalaallit oqaasii
|
194 |
+
km Central Khmer ភាសាខ្មែរ
|
195 |
+
kn Kannada ಕನ್ನಡ
|
196 |
+
ko Korean 한국어 (韓國語), 조선말 (朝鮮語)
|
197 |
+
kr Kanuri Kanuri
|
198 |
+
ks Kashmiri कश्मीरी, كشميري
|
199 |
+
ku Kurdish Kurdî, كوردی
|
200 |
+
kv Komi коми кыв
|
201 |
+
kw Cornish Kernewek
|
202 |
+
ky Kirghiz, Kyrgyz кыргыз тили
|
203 |
+
la Latin latine, lingua latina
|
204 |
+
lb Luxembourgish, Letzeburgesch Lëtzebuergesch
|
205 |
+
lg Ganda Luganda
|
206 |
+
li Limburgish, Limburgan, Limburger Limburgs
|
207 |
+
ln Lingala Lingála
|
208 |
+
lo Lao ພາສາລາວ
|
209 |
+
lt Lithuanian lietuvių kalba
|
210 |
+
lu Luba-Katanga
|
211 |
+
lv Latvian latviešu valoda
|
212 |
+
mg Malagasy Malagasy fiteny
|
213 |
+
mh Marshallese Kajin M̧ajeļ
|
214 |
+
mi Māori te reo Māori
|
215 |
+
mk Macedonian македонски јазик
|
216 |
+
ml Malayalam മലയാളം
|
217 |
+
mn Mongolian Монгол
|
218 |
+
mr Marathi मराठी
|
219 |
+
ms Malay bahasa Melayu, بهاس ملايو
|
220 |
+
mt Maltese Malti
|
221 |
+
my Burmese ဗမာစာ
|
222 |
+
na Nauru Ekakairũ Naoero
|
223 |
+
nb Norwegian Bokmål Norsk bokmål
|
224 |
+
nd North Ndebele isiNdebele
|
225 |
+
ne Nepali नेपाली
|
226 |
+
ng Ndonga Owambo
|
227 |
+
nl Dutch, Flemish Nederlands, Vlaams
|
228 |
+
nn Norwegian Nynorsk Norsk nynorsk
|
229 |
+
no Norwegian Norsk
|
230 |
+
nr South Ndebele isiNdebele
|
231 |
+
nv Navajo, Navaho Diné bizaad, Dinékʼehǰí
|
232 |
+
ny Chichewa, Chewa, Nyanja chiCheŵa, chinyanja
|
233 |
+
oc Occitan (after 1500) Occitan
|
234 |
+
oj Ojibwa ᐊᓂᔑᓈᐯᒧᐎᓐ
|
235 |
+
om Oromo Afaan Oromoo
|
236 |
+
or Oriya ଓଡ଼ିଆ
|
237 |
+
os Ossetian, Ossetic Ирон æвзаг
|
238 |
+
pa Panjabi, Punjabi ਪੰਜਾਬੀ, پنجابی
|
239 |
+
pi Pāli पाऴि
|
240 |
+
pl Polish polski
|
241 |
+
ps Pashto, Pushto پښتو
|
242 |
+
pt Portuguese Português
|
243 |
+
qu Quechua Runa Simi, Kichwa
|
244 |
+
rm Romansh rumantsch grischun
|
245 |
+
rn Rundi kiRundi
|
246 |
+
ro Romanian, Moldavian, Moldovan română
|
247 |
+
ru Russian Русский язык
|
248 |
+
rw Kinyarwanda Ikinyarwanda
|
249 |
+
sa Sanskrit संस्कृतम्
|
250 |
+
sc Sardinian sardu
|
251 |
+
sd Sindhi सिन्धी, سنڌي، سندھی
|
252 |
+
se Northern Sami Davvisámegiella
|
253 |
+
sg Sango yângâ tî sängö
|
254 |
+
si Sinhala, Sinhalese සිංහල
|
255 |
+
sk Slovak slovenčina
|
256 |
+
sl Slovene slovenščina
|
257 |
+
sm Samoan gagana fa'a Samoa
|
258 |
+
sn Shona chiShona
|
259 |
+
so Somali Soomaaliga, af Soomaali
|
260 |
+
sq Albanian Shqip
|
261 |
+
sr Serbian српски језик
|
262 |
+
ss Swati SiSwati
|
263 |
+
st Southern Sotho Sesotho
|
264 |
+
su Sundanese Basa Sunda
|
265 |
+
sv Swedish svenska
|
266 |
+
sw Swahili Kiswahili
|
267 |
+
ta Tamil தமிழ்
|
268 |
+
te Telugu తెలుగు
|
269 |
+
tg Tajik тоҷикӣ, toğikī, تاجیکی
|
270 |
+
th Thai ไทย
|
271 |
+
ti Tigrinya ትግርኛ
|
272 |
+
tk Turkmen Türkmen, Түркмен
|
273 |
+
tl Tagalog Wikang Tagalog, ᜏᜒᜃᜅ᜔ ᜆᜄᜎᜓᜄ᜔
|
274 |
+
tn Tswana Setswana
|
275 |
+
to Tonga (Tonga Islands) faka Tonga
|
276 |
+
tr Turkish Türkçe
|
277 |
+
ts Tsonga Xitsonga
|
278 |
+
tt Tatar татарча, tatarça, تاتارچا
|
279 |
+
tw Twi Twi
|
280 |
+
ty Tahitian Reo Mā`ohi
|
281 |
+
ug Uighur, Uyghur Uyƣurqə, ئۇيغۇرچە
|
282 |
+
uk Ukrainian Українська
|
283 |
+
ur Urdu اردو
|
284 |
+
uz Uzbek O'zbek, Ўзбек, أۇزبېك
|
285 |
+
ve Venda Tshivenḓa
|
286 |
+
vi Vietnamese Tiếng Việt
|
287 |
+
vo Volapük Volapük
|
288 |
+
wa Walloon Walon
|
289 |
+
wo Wolof Wollof
|
290 |
+
xh Xhosa isiXhosa
|
291 |
+
yi Yiddish ייִדיש
|
292 |
+
yo Yoruba Yorùbá
|
293 |
+
za Zhuang, Chuang Saɯ cueŋƅ, Saw cuengh
|
294 |
+
zh Chinese 中文 (Zhōngwén), 汉语, 漢語
|
295 |
+
zu Zulu isiZulu
|
296 |
+
|
297 |
+
*/
|
298 |
?>
|
css/transposh_widget.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.transposh_flags{direction:ltr;}.transposh_flags a:hover{background:transparent;}.transposh_flags a span,.transposh_flags a img{border-color:transparent;border-style:solid;border-width:1px 3px;padding:0;}.transposh_flags a span:hover,.transposh_flags a img:hover{border-color:blue;}
|
1 |
+
.transposh_flags{direction:ltr;line-height:0;}.transposh_flags a:hover{background:transparent;}.transposh_flags a span,.transposh_flags a img{border-color:transparent;border-style:solid;border-width:1px 3px;padding:0;}.transposh_flags a span:hover,.transposh_flags a img:hover{border-color:blue;}
|
img/bingicon.png
ADDED
Binary file
|
img/googleicon.png
ADDED
Binary file
|
img/rtlicon.png
ADDED
Binary file
|
js/transposhcontrol.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
jQuery(function(){jQuery("#tr_anon").click(function(){if(jQuery("#tr_anon").attr("checked")){jQuery(".translateable").addClass("active").removeClass("translateable");jQuery("#sortable .active").each(function(){jQuery("input",this).val(jQuery(this).attr("id")+",v,t")})}jQuery("#yellowcolor").toggleClass("hidden")});jQuery("#sortable").sortable({placeholder:"highlight",update:function(a,b){b.item.unbind("click");b.item.one("click",function(c){c.stopImmediatePropagation();jQuery(this).click(clickfunction)})}});jQuery("#sortable").disableSelection();jQuery("#changename").click(function(){jQuery(".langname").toggleClass("hidden");return false});jQuery("#selectall").click(function(){jQuery("#sortable .languages").addClass("active").removeClass("translateable");jQuery("#sortable .active").each(function(){jQuery("input",this).val(jQuery(this).attr("id")+",v,t")});return false});clickfunction=function(){if(jQuery(this).attr("id")==jQuery("#default_list li").attr("id")){return}if(jQuery("#tr_anon").attr("checked")){jQuery(this).toggleClass("active")}else{if(jQuery(this).hasClass("active")){jQuery(this).removeClass("active");jQuery(this).addClass("translateable")}else{if(jQuery(this).hasClass("translateable")){jQuery(this).removeClass("translateable")}else{jQuery(this).addClass("active")}}}jQuery("input",this).val(jQuery(this).attr("id")+(jQuery(this).hasClass("active")?",v":",")+(jQuery(this).hasClass("translateable")?",t":","))};jQuery(".languages").dblclick(clickfunction).click(clickfunction);jQuery("#default_lang").droppable({accept:".languages",activeClass:"highlight_default",drop:function(a,b){jQuery("#default_list").empty();jQuery(b.draggable.clone().removeAttr("style").removeClass("active").removeClass("translateable")).appendTo("#default_list").show("slow");jQuery("#default_list .logoicon").remove();jQuery("#sortable").find("#"+b.draggable.attr("id")).addClass("active")}});jQuery("#sortiso").click(function(){jQuery("#sortable li").sort(function(d,c){if(jQuery(d).attr("id")==jQuery("#default_list li").attr("id")){return -1}if(jQuery(c).attr("id")==jQuery("#default_list li").attr("id")){return 1}return jQuery(d).attr("id")>jQuery(c).attr("id")?1:-1}).remove().appendTo("#sortable").dblclick(clickfunction).click(clickfunction);return false});jQuery("#sortname").click(function(){jQuery("#sortable li").sort(function(d,c){langa=jQuery(".langname",d).filter(function(){return !jQuery(this).hasClass("hidden")}).text();langb=jQuery(".langname",c).filter(function(){return !jQuery(this).hasClass("hidden")}).text();langdef=jQuery(".langname","#default_list li").filter(function(){return !jQuery(this).hasClass("hidden")}).text();if(langa==langdef){return -1}if(langb==langdef){return 1}return langa>langb?1:-1}).remove().appendTo("#sortable").dblclick(clickfunction).click(clickfunction);return false})});
|
readme.txt
CHANGED
@@ -4,39 +4,43 @@ Donate link: http://transposh.org/donate/
|
|
4 |
Tags: translation, widget, filter, bilingual, multilingual, transposh, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese
|
5 |
Requires at least: 2.7
|
6 |
Tested up to: 2.9.0
|
7 |
-
Stable tag: 0.3.
|
8 |
|
9 |
Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
|
10 |
|
11 |
== Description ==
|
12 |
-
Transposh translation filter for WordPress offers a unique approach to blog translation. It allows your blog to
|
13 |
|
14 |
-
***
|
15 |
|
16 |
-
* Support for any language - including RTL/LTR
|
17 |
-
* Unique interface for choosing viewable/translatable languages
|
18 |
* Multiple selection for widget appearances
|
19 |
-
* Translation of external plugins
|
20 |
* Automatic translation mode for all content (including comments!)
|
|
|
|
|
|
|
21 |
* Translated languages are searchable
|
22 |
* Fine grained control for advanced users
|
23 |
|
24 |
-
***
|
25 |
|
26 |
* **Performance** - very fast - using APC cache if available
|
27 |
-
* **Support** - you want it - we'll implement it, visit our
|
28 |
* **Security** - we have externally audited the plugin for improved security
|
29 |
* **Ease of Use** - making translation as fun and as easy as possible
|
30 |
-
* **
|
|
|
31 |
|
32 |
-
Technology has been tested on a large dynamic site with millions of monthly page views. Feel free to visit [
|
33 |
|
34 |
== Installation ==
|
35 |
|
36 |
1. Upload the plugin to the `/wp-content/plugins/` directory
|
37 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
38 |
1. Add the widget to your side bar, decide which interface you prefer
|
39 |
-
1. On the settings page - define which languages you would like viewable, translatable and which language is currently used (default)
|
40 |
1. You may also elect to disable/enable the automatic translation mode
|
41 |
1. You are good to go
|
42 |
|
@@ -58,7 +62,7 @@ The correct place for that would be our [development site](http://trac.transposh
|
|
58 |
|
59 |
Another .css file might intervene with our in ways we didn't predict yet, either fix that .css alone or contact us
|
60 |
|
61 |
-
= What do the colors of the translation icons mean =
|
62 |
|
63 |
There are currently three colors used
|
64 |
|
@@ -66,7 +70,19 @@ There are currently three colors used
|
|
66 |
* Yellow - translation was done by a robot
|
67 |
* Green - translation was done by human (or approved by one)
|
68 |
|
69 |
-
=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
Wiki has proven itself quite a valid model on the Internet. More people have good intentions than bad intentions and that can be
|
72 |
harnessed to get your message out to more people. Future versions will give more focus on preventing spammers from defacing sites
|
@@ -75,7 +91,7 @@ harnessed to get your message out to more people. Future versions will give more
|
|
75 |
|
76 |
By default, automatic translation is on and it should be kicking in. If its off, and you don’t have enough privileges to translate, nothing will happen.
|
77 |
|
78 |
-
Please be reminded of the following “rules”
|
79 |
|
80 |
1. A language marked as viewable will have its flag shown inside the widget.
|
81 |
1. A language marked for editing will allow a translator (anyone marked in the ‘who can translate’ section) to manually edit the page. i.e. the translate check-box will appear in the widget.
|
@@ -92,7 +108,7 @@ functions so the transposh.js file is not being included, try to include it manu
|
|
92 |
|
93 |
Just add the following line to your template:
|
94 |
|
95 |
-
|
96 |
|
97 |
= I have php speedy (http://aciddrop.com/php-speedy/) and the plugin does not work =
|
98 |
|
@@ -104,22 +120,35 @@ Please make sure you are using PHP5 and up, PHP4 is not supported
|
|
104 |
|
105 |
= I want my own css image with less flags =
|
106 |
|
107 |
-
This is
|
108 |
|
109 |
= css flags have issues on IE6 for my users =
|
110 |
|
111 |
First, there's always the ability to use another option for the plugin which is more compatible, such as the selection box. Second, you can
|
112 |
change the .css from transparent background to your page background color. And last - we urge anyone using IE6 to upgrade...
|
113 |
|
|
|
|
|
|
|
|
|
114 |
== Screenshots ==
|
115 |
|
116 |
-
1. This is a screen shot of
|
117 |
-
2. This is the same site, translated to Hebrew
|
118 |
-
3. A look at the translation interface
|
119 |
-
4.
|
120 |
-
5. Widget style selection
|
|
|
|
|
|
|
|
|
121 |
|
122 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
123 |
= 2009/12/20 - 0.3.8 =
|
124 |
* Add language detection and default language settings
|
125 |
* Fix wrong inclusions of css and js (thanks [Kevin Hart](http://gainesvillecomputer.com/))
|
@@ -139,13 +168,13 @@ change the .css from transparent background to your page background color. And l
|
|
139 |
= 2009/11/26 - 0.3.5 =
|
140 |
* Enabled auto-translation to all editable languages on the admin side
|
141 |
* Alternate posting methods (thanks Andre)
|
142 |
-
* Fix
|
143 |
* Make sure simple_html_dom is not loaded twice (if we can...)
|
144 |
* Large scale code refactoring
|
145 |
* Migrated css flags to the widget settings
|
146 |
= 2009/11/05 - 0.3.4 =
|
147 |
* Fix for nextgen gallery issue
|
148 |
-
* Force LTR for wordpress blogs
|
149 |
* Avoid loading Bing Translate javascript when it is not needed
|
150 |
= 2009/09/06 - 0.3.3 =
|
151 |
* 9 More languages supported by google translate
|
@@ -157,7 +186,7 @@ change the .css from transparent background to your page background color. And l
|
|
157 |
= 2009/07/27 - 0.3.1 =
|
158 |
* Much faster caching of auto translation results on server with reduced server load
|
159 |
* Mark active language in the widget for css usage
|
160 |
-
* Fixed url code with
|
161 |
= 2009/07/23 - 0.3.0 =
|
162 |
* Support Bing (MSN) translator as a hinting facilitator
|
163 |
= 2009/07/21 - 0.2.9 =
|
@@ -184,11 +213,11 @@ change the .css from transparent background to your page background color. And l
|
|
184 |
* Fixed bugs with database prefixes (thanks again [Mike](http://www.nostate.com/))
|
185 |
* Translation of keywords and description meta tags (thanks again [Mike](http://www.nostate.com/))
|
186 |
* Fix for RSS feeds provided in other languages
|
187 |
-
* Fixed
|
188 |
* Support footer insertion of scripts in wordpress 2.8
|
189 |
* Fixed issues of html entities breaking when they should not (thanks [Karl](http://www.wp-plugin-archive.de/))
|
190 |
* Lang is now set in the headers for real
|
191 |
-
* Fixed
|
192 |
= 2009/06/03 - 0.2.3 =
|
193 |
* Revamped plugin setting page to a more useful one (code adapted from [code-styling.de](http://www.code-styling.de/))
|
194 |
* Widget settings may be changed from settings page (thanks [Db0](http://dbzer0.com/))
|
@@ -203,7 +232,7 @@ change the .css from transparent background to your page background color. And l
|
|
203 |
* Added language list mode to widget
|
204 |
* Prevent translation of url that is self wrapped
|
205 |
* Added <code> tag to list of ignored tags (thanks again [Mike](http://www.nostate.com/))
|
206 |
-
* Middle dot is now a
|
207 |
= 2009/05/18 - 0.2.0 =
|
208 |
* Faster parser - 50% faster parsing than previous engine (thanks [Simple Html DOM](http://simplehtmldom.sourceforge.net/))
|
209 |
* Hidden elements translation (mainly tooltips specified by title attribute)
|
4 |
Tags: translation, widget, filter, bilingual, multilingual, transposh, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese
|
5 |
Requires at least: 2.7
|
6 |
Tested up to: 2.9.0
|
7 |
+
Stable tag: 0.3.9
|
8 |
|
9 |
Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
|
10 |
|
11 |
== Description ==
|
12 |
+
Transposh translation filter for WordPress offers a unique approach to blog translation. It allows your blog to combine automatic translation with human translation aided by your users with an easy to use in-context interface.
|
13 |
|
14 |
+
***Transposh includes the following features:***
|
15 |
|
16 |
+
* Support for any language - including RTL/LTR layouts
|
17 |
+
* Unique drag/drop interface for choosing viewable/translatable languages
|
18 |
* Multiple selection for widget appearances
|
19 |
+
* Translation of external plugins without a need for .po/.mo files
|
20 |
* Automatic translation mode for all content (including comments!)
|
21 |
+
* Automatic translation can be triggered on demand by the readers or on the server side
|
22 |
+
* RSS feeds are translated too
|
23 |
+
* Takes care of hidden elements, link tags and titles
|
24 |
* Translated languages are searchable
|
25 |
* Fine grained control for advanced users
|
26 |
|
27 |
+
***Our goals:***
|
28 |
|
29 |
* **Performance** - very fast - using APC cache if available
|
30 |
+
* **Support** - you want it - we'll implement it, just visit our [development site](http://trac.transposh.org "ticket system")
|
31 |
* **Security** - we have externally audited the plugin for improved security
|
32 |
* **Ease of Use** - making translation as fun and as easy as possible
|
33 |
+
* **Flexibility** - allowing you to take control of the user experience
|
34 |
+
* **SEO** - search engines exposure increase
|
35 |
|
36 |
+
Technology has been thoroughly tested on a large dynamic site with millions of monthly page views. Feel free to visit [Colnect](http://colnect.com "website for collectors"), the best site for collectors.
|
37 |
|
38 |
== Installation ==
|
39 |
|
40 |
1. Upload the plugin to the `/wp-content/plugins/` directory
|
41 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
42 |
1. Add the widget to your side bar, decide which interface you prefer
|
43 |
+
1. On the settings page - define which languages you would like viewable, translatable and which language is currently used (default) by clicking and dragging
|
44 |
1. You may also elect to disable/enable the automatic translation mode
|
45 |
1. You are good to go
|
46 |
|
62 |
|
63 |
Another .css file might intervene with our in ways we didn't predict yet, either fix that .css alone or contact us
|
64 |
|
65 |
+
= What do the colors of the translation icons mean? =
|
66 |
|
67 |
There are currently three colors used
|
68 |
|
70 |
* Yellow - translation was done by a robot
|
71 |
* Green - translation was done by human (or approved by one)
|
72 |
|
73 |
+
= What are the colors in the administrative interface? =
|
74 |
+
|
75 |
+
Three background colors are used
|
76 |
+
* Green - this language is active and all users will see it
|
77 |
+
* Yellow - only users with translation capability can see this language (this is disabled once anonymous translation is available)
|
78 |
+
* Blank - language won't appear on widgets
|
79 |
+
|
80 |
+
= What is the dragging of languages for? =
|
81 |
+
|
82 |
+
You may drag the languages in order to set the order in which they appear in the widget, you can use the sorting links below
|
83 |
+
which will sort the languages and put the default language first. Dragging also is used to select the default language.
|
84 |
+
|
85 |
+
= Why should I allow anonymous translation? =
|
86 |
|
87 |
Wiki has proven itself quite a valid model on the Internet. More people have good intentions than bad intentions and that can be
|
88 |
harnessed to get your message out to more people. Future versions will give more focus on preventing spammers from defacing sites
|
91 |
|
92 |
By default, automatic translation is on and it should be kicking in. If its off, and you don’t have enough privileges to translate, nothing will happen.
|
93 |
|
94 |
+
Please be reminded of the following “rules of thumb”
|
95 |
|
96 |
1. A language marked as viewable will have its flag shown inside the widget.
|
97 |
1. A language marked for editing will allow a translator (anyone marked in the ‘who can translate’ section) to manually edit the page. i.e. the translate check-box will appear in the widget.
|
108 |
|
109 |
Just add the following line to your template:
|
110 |
|
111 |
+
`<?php if(function_exists("transposh_widget")) { transposh_widget(); }?>`
|
112 |
|
113 |
= I have php speedy (http://aciddrop.com/php-speedy/) and the plugin does not work =
|
114 |
|
120 |
|
121 |
= I want my own css image with less flags =
|
122 |
|
123 |
+
This is on our todo list
|
124 |
|
125 |
= css flags have issues on IE6 for my users =
|
126 |
|
127 |
First, there's always the ability to use another option for the plugin which is more compatible, such as the selection box. Second, you can
|
128 |
change the .css from transparent background to your page background color. And last - we urge anyone using IE6 to upgrade...
|
129 |
|
130 |
+
= How can I prevent certain text from being translated? =
|
131 |
+
|
132 |
+
You can wrap the element with the "no_translate" class, or add a span similar to `<span class="no_translate">`
|
133 |
+
|
134 |
== Screenshots ==
|
135 |
|
136 |
+
1. This is a screen shot of Transposh home page with the flagged widget on the right sidebar
|
137 |
+
2. This is the same site, translated to Hebrew, take note that automatic RTL kicked in
|
138 |
+
3. A look at the translation interface, in Spanish, viewable is the editor window and the icons used to trigger it in the background
|
139 |
+
4. The settings page, including management of active languages and various other settings
|
140 |
+
5. Widget style selection box, with three basic appearances, flags below (in Hebrew), language selection on the top right and language list on the bottom right.
|
141 |
+
|
142 |
+
== Upgrade Notice ==
|
143 |
+
= 0.3.9 =
|
144 |
+
This version allows sorting of languages within the widget
|
145 |
|
146 |
== Changelog ==
|
147 |
+
= 2009/12/26 - 0.3.9 =
|
148 |
+
* New languages interface, users can now sort languages on their widget
|
149 |
+
* anonymous translation is now on by default (for new installations)
|
150 |
+
* Changed the post option so it would just work (no need for the alternate settings)
|
151 |
+
* updated screenshots and FAQ
|
152 |
= 2009/12/20 - 0.3.8 =
|
153 |
* Add language detection and default language settings
|
154 |
* Fix wrong inclusions of css and js (thanks [Kevin Hart](http://gainesvillecomputer.com/))
|
168 |
= 2009/11/26 - 0.3.5 =
|
169 |
* Enabled auto-translation to all editable languages on the admin side
|
170 |
* Alternate posting methods (thanks Andre)
|
171 |
+
* Fix documentation display regarding widgetless themes (thanks [Hosein-mec](http://linuxshare.org/))
|
172 |
* Make sure simple_html_dom is not loaded twice (if we can...)
|
173 |
* Large scale code refactoring
|
174 |
* Migrated css flags to the widget settings
|
175 |
= 2009/11/05 - 0.3.4 =
|
176 |
* Fix for nextgen gallery issue
|
177 |
+
* Force LTR for wordpress blogs originating in RTL
|
178 |
* Avoid loading Bing Translate javascript when it is not needed
|
179 |
= 2009/09/06 - 0.3.3 =
|
180 |
* 9 More languages supported by google translate
|
186 |
= 2009/07/27 - 0.3.1 =
|
187 |
* Much faster caching of auto translation results on server with reduced server load
|
188 |
* Mark active language in the widget for css usage
|
189 |
+
* Fixed url code with parameters and subdirectories
|
190 |
= 2009/07/23 - 0.3.0 =
|
191 |
* Support Bing (MSN) translator as a hinting facilitator
|
192 |
= 2009/07/21 - 0.2.9 =
|
213 |
* Fixed bugs with database prefixes (thanks again [Mike](http://www.nostate.com/))
|
214 |
* Translation of keywords and description meta tags (thanks again [Mike](http://www.nostate.com/))
|
215 |
* Fix for RSS feeds provided in other languages
|
216 |
+
* Fixed compatibility to show support for wordpress 2.8
|
217 |
* Support footer insertion of scripts in wordpress 2.8
|
218 |
* Fixed issues of html entities breaking when they should not (thanks [Karl](http://www.wp-plugin-archive.de/))
|
219 |
* Lang is now set in the headers for real
|
220 |
+
* Fixed compatibility with themes using annoying query_posts with no consideration (thanks [Karl](http://www.wp-plugin-archive.de/))
|
221 |
= 2009/06/03 - 0.2.3 =
|
222 |
* Revamped plugin setting page to a more useful one (code adapted from [code-styling.de](http://www.code-styling.de/))
|
223 |
* Widget settings may be changed from settings page (thanks [Db0](http://dbzer0.com/))
|
232 |
* Added language list mode to widget
|
233 |
* Prevent translation of url that is self wrapped
|
234 |
* Added <code> tag to list of ignored tags (thanks again [Mike](http://www.nostate.com/))
|
235 |
+
* Middle dot is now a separator
|
236 |
= 2009/05/18 - 0.2.0 =
|
237 |
* Faster parser - 50% faster parsing than previous engine (thanks [Simple Html DOM](http://simplehtmldom.sourceforge.net/))
|
238 |
* Hidden elements translation (mainly tooltips specified by title attribute)
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
CHANGED
Binary file
|
screenshot-4.png
CHANGED
Binary file
|
screenshot-5.png
CHANGED
Binary file
|
transposh.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin URI: http://transposh.org/
|
5 |
Description: Translation filter for WordPress, After enabling please set languages at the <a href="options-general.php?page=transposh">the options page</a> Want to help? visit our development site at <a href="http://trac.transposh.org/">trac.transposh.org</a>.
|
6 |
Author: Team Transposh
|
7 |
-
Version: 0.3.
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
*/
|
@@ -33,12 +33,16 @@ if (!function_exists ('add_action')) {
|
|
33 |
exit();
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
36 |
require_once("core/parser.php");
|
37 |
-
require_once("transposh_db.php");
|
38 |
-
require_once("transposh_widget.php");
|
39 |
-
require_once("transposh_admin.php");
|
40 |
-
require_once("transposh_options.php");
|
41 |
-
require_once("transposh_postpublish.php");
|
42 |
|
43 |
/**
|
44 |
* This class represents the complete plugin
|
@@ -89,9 +93,6 @@ class transposh_plugin {
|
|
89 |
|
90 |
// "global" vars
|
91 |
$this->home_url = get_option('home');
|
92 |
-
$this->post_url = $this->home_url;
|
93 |
-
if ($this->options->get_alternate_post() == 1) $this->post_url .= "/";
|
94 |
-
if ($this->options->get_alternate_post() == 2) $this->post_url .= "/index.php";
|
95 |
|
96 |
// Handle windows ('C:\wordpress')
|
97 |
$local_dir = preg_replace("/\\\\/", "/", dirname(__FILE__));
|
@@ -101,6 +102,8 @@ class transposh_plugin {
|
|
101 |
// TODO - test on more platforms - this failed in 2.7.1 so I am reverting for now...
|
102 |
//$tr_plugin_url= plugins_url('', __FILE__);
|
103 |
|
|
|
|
|
104 |
|
105 |
|
106 |
//Register some functions into wordpress
|
@@ -184,38 +187,8 @@ class transposh_plugin {
|
|
184 |
$this->enable_permalinks_rewrite = TRUE;
|
185 |
}
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
$this->database->update_translation_new();
|
190 |
-
}
|
191 |
-
else {
|
192 |
-
$this->database->update_translation();
|
193 |
-
}
|
194 |
-
exit;
|
195 |
-
}
|
196 |
-
elseif (isset($_GET['tr_token_hist'])) {
|
197 |
-
$this->database->get_translation_history($_GET['tr_token_hist'], $_GET['lang']);
|
198 |
-
exit;
|
199 |
-
}
|
200 |
-
elseif (isset($_GET['tr_phrases_post'])) {
|
201 |
-
$this->postpublish->get_post_phrases($_GET['post']);
|
202 |
-
exit;
|
203 |
-
}
|
204 |
-
elseif (isset($_GET['tr_cookie'])) {
|
205 |
-
//$_COOKIE['TR_LNG'] = get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url);
|
206 |
-
setcookie('TR_LNG',get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url),time()+90*24*60*60,COOKIEPATH,COOKIE_DOMAIN);
|
207 |
-
|
208 |
-
exit;
|
209 |
-
}
|
210 |
-
elseif (isset($_GET['tr_cookie_bck'])) {
|
211 |
-
setcookie('TR_LNG',get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url),time()+90*24*60*60,COOKIEPATH,COOKIE_DOMAIN);
|
212 |
-
wp_redirect($_SERVER['HTTP_REFERER']);
|
213 |
-
exit;
|
214 |
-
}
|
215 |
-
else {
|
216 |
-
//set the callback for translating the page when it's done
|
217 |
-
ob_start(array(&$this,"process_page"));
|
218 |
-
}
|
219 |
}
|
220 |
|
221 |
/**
|
@@ -321,7 +294,7 @@ class transposh_plugin {
|
|
321 |
} else {
|
322 |
$bestlang = prefered_language(explode(',',$this->options->get_viewable_langs()),$this->options->get_default_language());
|
323 |
// we won't redirect if we should not, or this is a presumable bot
|
324 |
-
if ($bestlang && $bestlang != $this->target_language && $this->options->get_enable_detect_language() && !(preg_match("#(bot|yandex|google|jeeves|spider|crawler|slurp)#si", $_SERVER['HTTP_USER_AGENT']))) {
|
325 |
$url = rewrite_url_lang_param($_SERVER["REQUEST_URI"], $this->home_url, $this->enable_permalinks_rewrite, $bestlang,$this->edit_mode);
|
326 |
if ($this->options->is_default_language($bestlang)) $url = cleanup_url($_SERVER["REQUEST_URI"], $this->home_url);
|
327 |
wp_redirect($url);
|
@@ -493,7 +466,7 @@ class transposh_plugin {
|
|
493 |
* Insert references to the javascript files used in the translated version of the page.
|
494 |
*/
|
495 |
function add_transposh_js() {
|
496 |
-
|
497 |
if (!$this->edit_mode && !$this->is_auto_translate_permitted()) {
|
498 |
return;
|
499 |
}
|
4 |
Plugin URI: http://transposh.org/
|
5 |
Description: Translation filter for WordPress, After enabling please set languages at the <a href="options-general.php?page=transposh">the options page</a> Want to help? visit our development site at <a href="http://trac.transposh.org/">trac.transposh.org</a>.
|
6 |
Author: Team Transposh
|
7 |
+
Version: 0.3.9
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
*/
|
33 |
exit();
|
34 |
}
|
35 |
|
36 |
+
|
37 |
+
require_once("core/constants.php");
|
38 |
+
require_once("core/utils.php");
|
39 |
+
require_once("core/jsonwrapper/jsonwrapper.php");
|
40 |
require_once("core/parser.php");
|
41 |
+
require_once("wp/transposh_db.php");
|
42 |
+
require_once("wp/transposh_widget.php");
|
43 |
+
require_once("wp/transposh_admin.php");
|
44 |
+
require_once("wp/transposh_options.php");
|
45 |
+
require_once("wp/transposh_postpublish.php");
|
46 |
|
47 |
/**
|
48 |
* This class represents the complete plugin
|
93 |
|
94 |
// "global" vars
|
95 |
$this->home_url = get_option('home');
|
|
|
|
|
|
|
96 |
|
97 |
// Handle windows ('C:\wordpress')
|
98 |
$local_dir = preg_replace("/\\\\/", "/", dirname(__FILE__));
|
102 |
// TODO - test on more platforms - this failed in 2.7.1 so I am reverting for now...
|
103 |
//$tr_plugin_url= plugins_url('', __FILE__);
|
104 |
|
105 |
+
$this->post_url = $this->transposh_plugin_url."/wp/transposh_ajax.php";
|
106 |
+
|
107 |
|
108 |
|
109 |
//Register some functions into wordpress
|
187 |
$this->enable_permalinks_rewrite = TRUE;
|
188 |
}
|
189 |
|
190 |
+
//set the callback for translating the page when it's done
|
191 |
+
ob_start(array(&$this,"process_page"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
}
|
193 |
|
194 |
/**
|
294 |
} else {
|
295 |
$bestlang = prefered_language(explode(',',$this->options->get_viewable_langs()),$this->options->get_default_language());
|
296 |
// we won't redirect if we should not, or this is a presumable bot
|
297 |
+
if ($bestlang && $bestlang != $this->target_language && $this->options->get_enable_detect_language() && !(preg_match("#(bot|yandex|validator|google|jeeves|spider|crawler|slurp)#si", $_SERVER['HTTP_USER_AGENT']))) {
|
298 |
$url = rewrite_url_lang_param($_SERVER["REQUEST_URI"], $this->home_url, $this->enable_permalinks_rewrite, $bestlang,$this->edit_mode);
|
299 |
if ($this->options->is_default_language($bestlang)) $url = cleanup_url($_SERVER["REQUEST_URI"], $this->home_url);
|
300 |
wp_redirect($url);
|
466 |
* Insert references to the javascript files used in the translated version of the page.
|
467 |
*/
|
468 |
function add_transposh_js() {
|
469 |
+
//not in any translation mode - no need for any js.
|
470 |
if (!$this->edit_mode && !$this->is_auto_translate_permitted()) {
|
471 |
return;
|
472 |
}
|
transposh_admin.php → wp/transposh_admin.php
RENAMED
@@ -16,26 +16,22 @@
|
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
*
|
18 |
* adapted metabox sample code from http://www.code-styling.de/
|
19 |
-
|
20 |
|
21 |
/*
|
22 |
* Provide the admin page for configuring the translation options. eg. what languages ?
|
23 |
* who is allowed to translate ?
|
24 |
-
|
25 |
|
26 |
define ("TR_NONCE","transposh_nonce");
|
27 |
|
28 |
-
|
29 |
-
//class that reperesent the complete plugin
|
30 |
class transposh_plugin_admin {
|
31 |
/** @var transposh_plugin $transposh father class */
|
32 |
private $transposh;
|
33 |
//constructor of class, PHP4 compatible construction for backward compatibility
|
34 |
function transposh_plugin_admin(&$transposh) {
|
35 |
$this->transposh = &$transposh;
|
36 |
-
// FIX (probably always happens?)
|
37 |
-
if ($this->transposh->options->get_widget_css_flags())
|
38 |
-
wp_enqueue_style("transposh_flags",plugins_url('', __FILE__)."/css/transposh_flags.css",array(),TRANSPOSH_PLUGIN_VER);
|
39 |
//add filter for WordPress 2.8 changed backend box system !
|
40 |
add_filter('screen_layout_columns', array(&$this, 'on_screen_layout_columns'), 10, 2);
|
41 |
//add some help
|
@@ -46,10 +42,10 @@ class transposh_plugin_admin {
|
|
46 |
add_action('admin_post_save_transposh', array(&$this, 'on_save_changes'));
|
47 |
}
|
48 |
|
49 |
-
/*
|
50 |
* Indicates whether the given role can translate.
|
51 |
* Return either "checked" or ""
|
52 |
-
|
53 |
function can_translate($role_name) {
|
54 |
if($role_name != 'anonymous') {
|
55 |
$role = $GLOBALS['wp_roles']->get_role($role_name);
|
@@ -60,9 +56,9 @@ class transposh_plugin_admin {
|
|
60 |
return ($this->transposh->options->get_anonymous_translation()) ? 'checked="checked"' : '';
|
61 |
}
|
62 |
//
|
63 |
-
/*
|
64 |
* Handle newly posted admin options.
|
65 |
-
|
66 |
function update_admin_options() {
|
67 |
|
68 |
|
@@ -81,22 +77,30 @@ class transposh_plugin_admin {
|
|
81 |
//Anonymous needs to be handled differently as it does not have a role
|
82 |
$this->transposh->options->set_anonymous_translation($_POST['anonymous']);
|
83 |
|
84 |
-
//
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
// force that every viewable lang is editable
|
89 |
-
$editable_langs[$
|
90 |
}
|
91 |
|
92 |
-
if($
|
93 |
-
$editable_langs[$
|
94 |
}
|
95 |
}
|
96 |
|
97 |
$this->transposh->options->set_viewable_langs(implode(',', $viewable_langs));
|
98 |
$this->transposh->options->set_editable_langs(implode(',', $editable_langs));
|
99 |
-
$this->transposh->options->
|
100 |
|
101 |
if($this->transposh->options->get_enable_permalinks() != $_POST[ENABLE_PERMALINKS]) {
|
102 |
$this->transposh->options->set_enable_permalinks($_POST[ENABLE_PERMALINKS]);
|
@@ -106,7 +110,6 @@ class transposh_plugin_admin {
|
|
106 |
}
|
107 |
|
108 |
$this->transposh->options->set_enable_footer_scripts($_POST[ENABLE_FOOTER_SCRIPTS]);
|
109 |
-
$this->transposh->options->set_alternate_post($_POST[ALTERNATE_POST]);
|
110 |
$this->transposh->options->set_enable_detect_language($_POST[ENABLE_DETECT_LANG_AND_REDIRECT]);
|
111 |
$this->transposh->options->set_enable_auto_translate($_POST[ENABLE_AUTO_TRANSLATE]);
|
112 |
$this->transposh->options->set_enable_auto_post_translate($_POST[ENABLE_AUTO_POST_TRANSLATE]);
|
@@ -130,8 +133,8 @@ class transposh_plugin_admin {
|
|
130 |
function on_contextual_help($filterVal,$screen) {
|
131 |
if($screen == "settings_page_transposh") {
|
132 |
$filterVal["settings_page_transposh"] = '<p>Transposh makes your blog translatable</p>'.
|
133 |
-
|
134 |
-
|
135 |
}
|
136 |
return $filterVal;
|
137 |
}
|
@@ -153,6 +156,11 @@ class transposh_plugin_admin {
|
|
153 |
wp_enqueue_script('wp-lists');
|
154 |
wp_enqueue_script('postbox');
|
155 |
|
|
|
|
|
|
|
|
|
|
|
156 |
//add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
|
157 |
add_meta_box('transposh-sidebox-about', 'About this plugin', array(&$this, 'on_sidebox_about_content'), $this->pagehook, 'side', 'core');
|
158 |
add_meta_box('transposh-sidebox-widget', 'Widget settings', array(&$this, 'on_sidebox_widget_content'), $this->pagehook, 'side', 'core');
|
@@ -195,7 +203,7 @@ class transposh_plugin_admin {
|
|
195 |
<div id="post-body" class="has-sidebar">
|
196 |
<div id="post-body-content" class="has-sidebar-content">
|
197 |
<?php do_meta_boxes($this->pagehook, 'normal', "");
|
198 |
-
|
199 |
//do_meta_boxes($this->pagehook, 'additional', $data); ?>
|
200 |
<p>
|
201 |
<input type="submit" value="Save Changes" class="button-primary" name="Submit"/>
|
@@ -268,13 +276,13 @@ class transposh_plugin_admin {
|
|
268 |
|
269 |
foreach ( (array) $rss->items as $item ) {
|
270 |
printf(
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
);
|
279 |
}
|
280 |
|
@@ -293,67 +301,87 @@ class transposh_plugin_admin {
|
|
293 |
$this->transposh->database->db_stats();
|
294 |
}
|
295 |
|
|
|
|
|
|
|
|
|
296 |
function on_contentbox_languages_content($data) {
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
if ($this->can_translate('anonymous')) $extrastyle = ' style ="display:none"';
|
322 |
-
|
323 |
-
$columns = 2;
|
324 |
-
for($hdr=0; $hdr < $columns; $hdr++) {
|
325 |
-
$extrapad = ($hdr != $columns - 1) ? ";padding-right: 40px" : '';
|
326 |
-
echo '<th style="text-align:left; width:'.(100/$columns).'%">Language</th>'.
|
327 |
-
'<th title="Is this language user selectable?">Viewable</th>'.
|
328 |
-
'<th title="Is this language visible for translators?"'.$extrastyle.' class="tr_editable">Translatable</th>'.
|
329 |
-
'<th>Default</th>'.
|
330 |
-
'<th style="text-align:left;width: 80px'.$extrapad.'" title="Can we auto-translate this language?">Auto?</th>';
|
331 |
}
|
332 |
-
|
333 |
-
|
334 |
-
$i=0;
|
335 |
-
foreach($GLOBALS['languages'] as $code => $lang) {
|
336 |
-
list ($language,$flag,$autot) = explode (",",$lang);
|
337 |
-
if(!($i % $columns)) echo '<tr'.(!($i/2 % $columns) ? ' class="alternate"':'').'>';
|
338 |
-
$i++;
|
339 |
-
|
340 |
-
echo "<td>".display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, $language,$this->transposh->options->get_widget_css_flags())." $language</td>";
|
341 |
-
echo '<td align="center"><input type="checkbox" id="' . $code .'_view" name="' .
|
342 |
-
$code . '_view" onchange="chbx_change(\'' . $code . '\')" ' . $this->checked($this->transposh->options->is_viewable_language($code)) . '/></td>';
|
343 |
-
echo '<td class="tr_editable"'.$extrastyle.' align="center"><input type="checkbox" id="' . $code . '_edit" name="' .
|
344 |
-
$code . '_edit" ' . $this->checked($this->transposh->options->is_editable_language($code)). '/></td>';
|
345 |
-
echo "<td align=\"center\"><input type=\"radio\" name=\"default_lang\" value=\"$code\" " .
|
346 |
-
$this->checked($this->transposh->options->is_default_language($code)). "/></td>";
|
347 |
-
// TODO: Add icons?
|
348 |
-
echo "<td>".($autot ? "Y" : "N")."</td>";
|
349 |
-
|
350 |
-
if(!($i % $columns)) echo '</tr>';
|
351 |
}
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
}
|
358 |
|
359 |
/**
|
@@ -368,12 +396,12 @@ class transposh_plugin_admin {
|
|
368 |
function on_contentbox_translation_content($data) {
|
369 |
/*
|
370 |
* Insert permissions section in the admin page
|
371 |
-
|
372 |
echo '<h4>Who can translate ?</h4>';
|
373 |
//display known roles and their permission to translate
|
374 |
foreach($GLOBALS['wp_roles']->get_names() as $role_name => $something) {
|
375 |
echo '<input type="checkbox" value="1" name="'.$role_name.'" '.$this->can_translate($role_name).
|
376 |
-
|
377 |
}
|
378 |
//Add our own custom role
|
379 |
echo '<input id="tr_anon" type="checkbox" value="1" name="anonymous" '. $this->can_translate('anonymous') . '/> Anonymous';
|
@@ -381,10 +409,10 @@ class transposh_plugin_admin {
|
|
381 |
/*
|
382 |
* Insert the option to enable/disable automatic translation.
|
383 |
* Enabled by default.
|
384 |
-
|
385 |
echo '<h4>Enable automatic translation</h4>';
|
386 |
echo '<input type="checkbox" value="1" name="'.ENABLE_AUTO_TRANSLATE.'" '.$this->checked($this->transposh->options->get_enable_auto_translate()).'/> '.
|
387 |
-
|
388 |
|
389 |
/**
|
390 |
* Insert the option to enable/disable automatic translation upon publishing.
|
@@ -392,24 +420,24 @@ class transposh_plugin_admin {
|
|
392 |
* @since 0.3.5 */
|
393 |
echo '<h4>New - Enable automatic translation after posting</h4>';
|
394 |
echo '<input type="checkbox" value="1" name="'.ENABLE_AUTO_POST_TRANSLATE.'" '.$this->checked($this->transposh->options->get_enable_auto_post_translate()).'/> '.
|
395 |
-
|
396 |
|
397 |
/*
|
398 |
* Insert the option to enable/disable msn translations.
|
399 |
* Disabled by default because an API key is needed.
|
400 |
-
|
401 |
echo '<h4>Support for Bing (MSN) translation hinting (experimental)</h4>';
|
402 |
echo '<input type="checkbox" value="1" name="'.ENABLE_MSN_TRANSLATE.'" '.$this->checked($this->transposh->options->get_enable_msn_translate()).'/> '.
|
403 |
-
|
404 |
-
|
405 |
|
406 |
/*
|
407 |
* Insert the option to enable/disable default language translation.
|
408 |
* Disabled by default.
|
409 |
-
|
410 |
echo '<h4>Enable default language translation</h4>';
|
411 |
echo '<input type="checkbox" value="1" name="'.ENABLE_DEFAULT_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_default_translate()).'/> '.
|
412 |
-
|
413 |
|
414 |
/**
|
415 |
* Insert the option to enable search in translated languages
|
@@ -418,7 +446,7 @@ class transposh_plugin_admin {
|
|
418 |
*/
|
419 |
echo '<h4>Enable search in translated languages</h4>';
|
420 |
echo '<input type="checkbox" value="1" name="'.ENABLE_SEARCH_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_search_translate()).'/> '.
|
421 |
-
|
422 |
|
423 |
}
|
424 |
|
@@ -426,50 +454,33 @@ class transposh_plugin_admin {
|
|
426 |
/*
|
427 |
* Insert the option to enable/disable rewrite of perlmalinks.
|
428 |
* When disabled only parameters will be used to identify the current language.
|
429 |
-
|
430 |
echo '<h4>Rewrite URLs</h4>';
|
431 |
echo '<input type="checkbox" value="1" name="'.ENABLE_PERMALINKS.'" '. $this->checked($this->transposh->options->get_enable_permalinks()) . '/> '.
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
|
436 |
/*
|
437 |
* Insert the option to enable/disable pushing of scripts to footer.
|
438 |
* Works on wordpress 2.8 and up
|
439 |
-
|
440 |
if (floatval($GLOBALS['wp_version']) >= 2.8) {
|
441 |
echo '<h4>Add scripts to footer</h4>';
|
442 |
echo '<input type="checkbox" value="1" name="'.ENABLE_FOOTER_SCRIPTS.'" '. $this->checked($this->transposh->options->get_enable_footer_scripts()) . '/> '.
|
443 |
-
|
444 |
-
|
445 |
}
|
446 |
|
447 |
-
/**
|
448 |
-
* Allow some alternate posting methods support
|
449 |
-
* @since 0.3.5 */
|
450 |
-
echo '<h4>Try alternate posting methods</h4>';
|
451 |
-
|
452 |
-
echo '<select name="'.ALTERNATE_POST.'" id="'.ALTERNATE_POST.'">';
|
453 |
-
echo '<option value="0" '.(($this->transposh->options->get_alternate_post() == 0) ? 'selected=""':'').'>Normal</option>';
|
454 |
-
echo '<option value="1" '.(($this->transposh->options->get_alternate_post() == 1) ? 'selected=""':'').'>Added "/"</option>';
|
455 |
-
echo '<option value="2" '.(($this->transposh->options->get_alternate_post() == 2) ? 'selected=""':'').'>Added "/index.php"</option>';
|
456 |
-
echo '</select> ';
|
457 |
-
echo 'Change this option only if changes fail to get saved on the database';
|
458 |
-
|
459 |
/**
|
460 |
* Insert the option to enable/disable language auto-detection
|
461 |
* @since 0.3.8 */
|
462 |
-
|
463 |
-
|
464 |
'This enables auto detection of language used by the user as defined in the ACCEPT_LANGUAGES they send. '.
|
465 |
'This will redirect the first page accessed in the session to the same page with the detected language.';
|
466 |
|
467 |
-
|
468 |
-
/*foreach($languages as $code => $lang) {
|
469 |
-
list ($language,$flag,$autot) = explode (",",$lang);
|
470 |
-
$flags .= $flag.',';
|
471 |
-
}
|
472 |
-
* WIP2
|
473 |
echo '<a href="http://transposh.org/services/index.php?flags='.$flags.'">Gen sprites</a>';*/
|
474 |
}
|
475 |
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
*
|
18 |
* adapted metabox sample code from http://www.code-styling.de/
|
19 |
+
*/
|
20 |
|
21 |
/*
|
22 |
* Provide the admin page for configuring the translation options. eg. what languages ?
|
23 |
* who is allowed to translate ?
|
24 |
+
*/
|
25 |
|
26 |
define ("TR_NONCE","transposh_nonce");
|
27 |
|
28 |
+
//class that reperesent the admin page
|
|
|
29 |
class transposh_plugin_admin {
|
30 |
/** @var transposh_plugin $transposh father class */
|
31 |
private $transposh;
|
32 |
//constructor of class, PHP4 compatible construction for backward compatibility
|
33 |
function transposh_plugin_admin(&$transposh) {
|
34 |
$this->transposh = &$transposh;
|
|
|
|
|
|
|
35 |
//add filter for WordPress 2.8 changed backend box system !
|
36 |
add_filter('screen_layout_columns', array(&$this, 'on_screen_layout_columns'), 10, 2);
|
37 |
//add some help
|
42 |
add_action('admin_post_save_transposh', array(&$this, 'on_save_changes'));
|
43 |
}
|
44 |
|
45 |
+
/*
|
46 |
* Indicates whether the given role can translate.
|
47 |
* Return either "checked" or ""
|
48 |
+
*/
|
49 |
function can_translate($role_name) {
|
50 |
if($role_name != 'anonymous') {
|
51 |
$role = $GLOBALS['wp_roles']->get_role($role_name);
|
56 |
return ($this->transposh->options->get_anonymous_translation()) ? 'checked="checked"' : '';
|
57 |
}
|
58 |
//
|
59 |
+
/*
|
60 |
* Handle newly posted admin options.
|
61 |
+
*/
|
62 |
function update_admin_options() {
|
63 |
|
64 |
|
77 |
//Anonymous needs to be handled differently as it does not have a role
|
78 |
$this->transposh->options->set_anonymous_translation($_POST['anonymous']);
|
79 |
|
80 |
+
//first set the default language
|
81 |
+
list ($langcode, $viewable, $translateable) = explode(",",$_POST['languages'][0]);
|
82 |
+
$this->transposh->options->set_default_language($langcode);
|
83 |
+
unset($_POST['languages'][0]);
|
84 |
+
|
85 |
+
//Update the list of supported/editable/sortable languages
|
86 |
+
|
87 |
+
foreach($_POST['languages'] as $code => $lang) {
|
88 |
+
list ($langcode, $viewable, $translateable) = explode(",",$lang);
|
89 |
+
$sorted_langs[$langcode] = $langcode;
|
90 |
+
if($viewable) {
|
91 |
+
$viewable_langs[$langcode] = $langcode;
|
92 |
// force that every viewable lang is editable
|
93 |
+
$editable_langs[$langcode] = $langcode;
|
94 |
}
|
95 |
|
96 |
+
if($translateable) {
|
97 |
+
$editable_langs[$langcode] = $langcode;
|
98 |
}
|
99 |
}
|
100 |
|
101 |
$this->transposh->options->set_viewable_langs(implode(',', $viewable_langs));
|
102 |
$this->transposh->options->set_editable_langs(implode(',', $editable_langs));
|
103 |
+
$this->transposh->options->set_sorted_langs(implode(',', $sorted_langs));
|
104 |
|
105 |
if($this->transposh->options->get_enable_permalinks() != $_POST[ENABLE_PERMALINKS]) {
|
106 |
$this->transposh->options->set_enable_permalinks($_POST[ENABLE_PERMALINKS]);
|
110 |
}
|
111 |
|
112 |
$this->transposh->options->set_enable_footer_scripts($_POST[ENABLE_FOOTER_SCRIPTS]);
|
|
|
113 |
$this->transposh->options->set_enable_detect_language($_POST[ENABLE_DETECT_LANG_AND_REDIRECT]);
|
114 |
$this->transposh->options->set_enable_auto_translate($_POST[ENABLE_AUTO_TRANSLATE]);
|
115 |
$this->transposh->options->set_enable_auto_post_translate($_POST[ENABLE_AUTO_POST_TRANSLATE]);
|
133 |
function on_contextual_help($filterVal,$screen) {
|
134 |
if($screen == "settings_page_transposh") {
|
135 |
$filterVal["settings_page_transposh"] = '<p>Transposh makes your blog translatable</p>'.
|
136 |
+
'<a href="http://transposh.org/">Plugin homepage</a><br/>'.
|
137 |
+
'<a href="http://transposh.org/faq/">Frequently asked questions</a>';
|
138 |
}
|
139 |
return $filterVal;
|
140 |
}
|
156 |
wp_enqueue_script('wp-lists');
|
157 |
wp_enqueue_script('postbox');
|
158 |
|
159 |
+
if ($this->transposh->options->get_widget_css_flags())
|
160 |
+
wp_enqueue_style("transposh_flags",$this->transposh->transposh_plugin_url."/css/transposh_flags.css",array(),TRANSPOSH_PLUGIN_VER);
|
161 |
+
wp_enqueue_script('jquery-ui-droppable');
|
162 |
+
wp_enqueue_script("transposh_control",$this->transposh->transposh_plugin_url."/js/transposhcontrol.js",array(),TRANSPOSH_PLUGIN_VER, true);
|
163 |
+
|
164 |
//add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
|
165 |
add_meta_box('transposh-sidebox-about', 'About this plugin', array(&$this, 'on_sidebox_about_content'), $this->pagehook, 'side', 'core');
|
166 |
add_meta_box('transposh-sidebox-widget', 'Widget settings', array(&$this, 'on_sidebox_widget_content'), $this->pagehook, 'side', 'core');
|
203 |
<div id="post-body" class="has-sidebar">
|
204 |
<div id="post-body-content" class="has-sidebar-content">
|
205 |
<?php do_meta_boxes($this->pagehook, 'normal', "");
|
206 |
+
/* Maybe add static content here later */
|
207 |
//do_meta_boxes($this->pagehook, 'additional', $data); ?>
|
208 |
<p>
|
209 |
<input type="submit" value="Save Changes" class="button-primary" name="Submit"/>
|
276 |
|
277 |
foreach ( (array) $rss->items as $item ) {
|
278 |
printf(
|
279 |
+
'<li><a href="%1$s" title="%2$s">%3$s</a></li>',
|
280 |
+
//esc_url( $item['link'] ),
|
281 |
+
//esc_attr( strip_tags( $item['description'] ) ),
|
282 |
+
// TODO - check Switched to 2.7 compatability functions
|
283 |
+
clean_url( $item['link'] ),
|
284 |
+
attribute_escape( strip_tags( $item['description'] ) ),
|
285 |
+
htmlentities( $item['title'],ENT_COMPAT,'UTF-8' )
|
286 |
);
|
287 |
}
|
288 |
|
301 |
$this->transposh->database->db_stats();
|
302 |
}
|
303 |
|
304 |
+
/**
|
305 |
+
* Insert supported languages section in admin page
|
306 |
+
* @param string $data
|
307 |
+
*/
|
308 |
function on_contentbox_languages_content($data) {
|
309 |
+
// we need some styles
|
310 |
+
echo '<style type="text/css">
|
311 |
+
#sortable { list-style-type: none; margin: 0; padding: 0; }
|
312 |
+
#sortable li, #default_lang li { margin: 3px 3px 3px 0; padding: 5px; float: left; width: 190px; height: 14px;}
|
313 |
+
.languages {
|
314 |
+
-moz-border-radius: 6px;
|
315 |
+
-khtml-border-radius: 6px;
|
316 |
+
-webkit-border-radius: 6px;
|
317 |
+
border-radius: 6px;
|
318 |
+
border-style:solid;
|
319 |
+
border-width:1px;
|
320 |
+
line-height:1;
|
321 |
+
}
|
322 |
+
.highlight {
|
323 |
+
-moz-border-radius: 6px;
|
324 |
+
-khtml-border-radius: 6px;
|
325 |
+
-webkit-border-radius: 6px;
|
326 |
+
border-radius: 6px;
|
327 |
+
border-style:solid;
|
328 |
+
border-width:1px;
|
329 |
+
line-height:1;
|
330 |
+
background: #FFE45C;
|
331 |
+
width: 190px;
|
332 |
+
height: 14px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
}
|
334 |
+
.highlight_default {
|
335 |
+
background: #FFE45C;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
}
|
337 |
+
.active {
|
338 |
+
background: #45FF51;
|
339 |
+
}
|
340 |
+
.translateable {
|
341 |
+
background: #FFFF51;
|
342 |
+
}
|
343 |
+
.hidden {
|
344 |
+
display: none;
|
345 |
+
}
|
346 |
+
.logoicon {
|
347 |
+
float: right;
|
348 |
+
margin-left:2px;
|
349 |
+
margin-top:-1px;
|
350 |
+
}
|
351 |
+
</style>';
|
352 |
+
|
353 |
+
// this is the default language location
|
354 |
+
list ($langname, $langorigname,$flag) = explode (",",$GLOBALS['languages'][$this->transposh->options->get_default_language()]);
|
355 |
+
echo '<div id="default_lang" style="overflow:auto;padding-bottom:10px;">Default Language (drag another language here to make it default)';
|
356 |
+
echo '<ul id="default_list"><li id="'.$this->transposh->options->get_default_language().'" class="languages">'
|
357 |
+
.display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, $langorigname,$this->transposh->options->get_widget_css_flags())
|
358 |
+
.'<input type="hidden" name="languages[]" value="'. $this->transposh->options->get_default_language() .'" />'
|
359 |
+
.' <span class="langname">'.$langorigname.'</span><span class="langname hidden">'.$langname.'</span></li>';
|
360 |
+
echo '</ul></div>';
|
361 |
+
// list of languages
|
362 |
+
echo '<div style="overflow:auto; clear: both;">Available Languages (Click to toggle language state - Drag to sort in the widget)';
|
363 |
+
echo '<ul id="sortable">';
|
364 |
+
foreach($this->transposh->options->get_sorted_langs() as $langcode => $langrecord) {
|
365 |
+
list ($langname, $langorigname,$flag) = explode (",",$langrecord);
|
366 |
+
echo '<li id="'.$langcode.'" class="languages '.($this->transposh->options->is_viewable_language($langcode) || $this->transposh->options->is_default_language($langcode) ? "active" : "")
|
367 |
+
.(!$this->transposh->options->is_viewable_language($langcode) && $this->transposh->options->is_editable_language($langcode) ? "translateable" : "") .'"><div style="float:left">'
|
368 |
+
.display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, $langorigname,$this->transposh->options->get_widget_css_flags())
|
369 |
+
.'<input type="hidden" name="languages[]" value="'. $langcode .($this->transposh->options->is_viewable_language($langcode) ? ",v" : ",").($this->transposh->options->is_viewable_language($langcode) ? ",t" : ",").'" />'
|
370 |
+
.' <span class="langname">'.$langorigname.'</span><span class="langname hidden">'.$langname.'</span></div>';
|
371 |
+
if (in_array($langcode,$GLOBALS['google_languages'])) echo "<img width=\"16\" height=\"16\" alt=\"g\" class=\"logoicon\" title=\"Language supported by google translate\" src=\"{$this->transposh->transposh_plugin_url}/img/googleicon.png\"/>";
|
372 |
+
if (in_array($langcode,$GLOBALS['bing_languages'])) echo "<img width=\"16\" height=\"16\" alt=\"b\" class=\"logoicon\" title=\"Language supported by bing translate\" src=\"{$this->transposh->transposh_plugin_url}/img/bingicon.png\"/>";
|
373 |
+
if (in_array($langcode,$GLOBALS['rtl_languages'])) echo "<img width=\"16\" height=\"16\" alt=\"r\" class=\"logoicon\" title=\"Language is written from right to left\" src=\"{$this->transposh->transposh_plugin_url}/img/rtlicon.png\"/>";
|
374 |
+
echo '</li>';
|
375 |
+
}
|
376 |
+
echo "</ul></div>";
|
377 |
+
// options to play with
|
378 |
+
echo '<div style="clear: both;">Display options:<br/><ul style="list-style-type: disc; margin-left: 20px;font-size:11px">';
|
379 |
+
echo '<li><a href="#" id="changename">Toggle names of languages between English and Original</a></li>';
|
380 |
+
echo '<li><a href="#" id="selectall">Make all languages active</a></li>';
|
381 |
+
echo '<li><a href="#" id="sortname">Sort by language name</a></li>';
|
382 |
+
echo '<li><a href="#" id="sortiso">Sort by lSO code</a></li></ul>';
|
383 |
+
echo 'Legend: Green - active, <span id="yellowcolor" class="'.($this->transposh->options->get_anonymous_translation() ? "hidden" : "").'">Yellow - translateable (only translators will see this language), </span>blank - inactive';
|
384 |
+
echo '</div>';
|
385 |
}
|
386 |
|
387 |
/**
|
396 |
function on_contentbox_translation_content($data) {
|
397 |
/*
|
398 |
* Insert permissions section in the admin page
|
399 |
+
*/
|
400 |
echo '<h4>Who can translate ?</h4>';
|
401 |
//display known roles and their permission to translate
|
402 |
foreach($GLOBALS['wp_roles']->get_names() as $role_name => $something) {
|
403 |
echo '<input type="checkbox" value="1" name="'.$role_name.'" '.$this->can_translate($role_name).
|
404 |
+
'/> '.ucfirst($role_name).' ';
|
405 |
}
|
406 |
//Add our own custom role
|
407 |
echo '<input id="tr_anon" type="checkbox" value="1" name="anonymous" '. $this->can_translate('anonymous') . '/> Anonymous';
|
409 |
/*
|
410 |
* Insert the option to enable/disable automatic translation.
|
411 |
* Enabled by default.
|
412 |
+
*/
|
413 |
echo '<h4>Enable automatic translation</h4>';
|
414 |
echo '<input type="checkbox" value="1" name="'.ENABLE_AUTO_TRANSLATE.'" '.$this->checked($this->transposh->options->get_enable_auto_translate()).'/> '.
|
415 |
+
'Allow automatic translation of pages (currently using Google Translate)';
|
416 |
|
417 |
/**
|
418 |
* Insert the option to enable/disable automatic translation upon publishing.
|
420 |
* @since 0.3.5 */
|
421 |
echo '<h4>New - Enable automatic translation after posting</h4>';
|
422 |
echo '<input type="checkbox" value="1" name="'.ENABLE_AUTO_POST_TRANSLATE.'" '.$this->checked($this->transposh->options->get_enable_auto_post_translate()).'/> '.
|
423 |
+
'Do automatic translation immediately after a post has been published';
|
424 |
|
425 |
/*
|
426 |
* Insert the option to enable/disable msn translations.
|
427 |
* Disabled by default because an API key is needed.
|
428 |
+
*/
|
429 |
echo '<h4>Support for Bing (MSN) translation hinting (experimental)</h4>';
|
430 |
echo '<input type="checkbox" value="1" name="'.ENABLE_MSN_TRANSLATE.'" '.$this->checked($this->transposh->options->get_enable_msn_translate()).'/> '.
|
431 |
+
'Allow MSN (Bing) translator hinting (get key from <a href="http://www.microsofttranslator.com/Dev/Ajax/Default.aspx">here</a>)<br/>'.
|
432 |
+
'Key: <input type="text" size="35" class="regular-text" value="'.$this->transposh->options->get_msn_key().'" id="'.MSN_TRANSLATE_KEY.'" name="'.MSN_TRANSLATE_KEY.'"/>';
|
433 |
|
434 |
/*
|
435 |
* Insert the option to enable/disable default language translation.
|
436 |
* Disabled by default.
|
437 |
+
*/
|
438 |
echo '<h4>Enable default language translation</h4>';
|
439 |
echo '<input type="checkbox" value="1" name="'.ENABLE_DEFAULT_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_default_translate()).'/> '.
|
440 |
+
'Allow translation of default language - useful for sites with more than one major language';
|
441 |
|
442 |
/**
|
443 |
* Insert the option to enable search in translated languages
|
446 |
*/
|
447 |
echo '<h4>Enable search in translated languages</h4>';
|
448 |
echo '<input type="checkbox" value="1" name="'.ENABLE_SEARCH_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_search_translate()).'/> '.
|
449 |
+
'Allow search of translated languages, in those languages (and the original language)';
|
450 |
|
451 |
}
|
452 |
|
454 |
/*
|
455 |
* Insert the option to enable/disable rewrite of perlmalinks.
|
456 |
* When disabled only parameters will be used to identify the current language.
|
457 |
+
*/
|
458 |
echo '<h4>Rewrite URLs</h4>';
|
459 |
echo '<input type="checkbox" value="1" name="'.ENABLE_PERMALINKS.'" '. $this->checked($this->transposh->options->get_enable_permalinks()) . '/> '.
|
460 |
+
'Rewrite URLs to be search engine friendly, '.
|
461 |
+
'e.g. (http://wordpress.org/<strong>en</strong>). '.
|
462 |
+
'Requires that permalinks will be enabled.';
|
463 |
|
464 |
/*
|
465 |
* Insert the option to enable/disable pushing of scripts to footer.
|
466 |
* Works on wordpress 2.8 and up
|
467 |
+
*/
|
468 |
if (floatval($GLOBALS['wp_version']) >= 2.8) {
|
469 |
echo '<h4>Add scripts to footer</h4>';
|
470 |
echo '<input type="checkbox" value="1" name="'.ENABLE_FOOTER_SCRIPTS.'" '. $this->checked($this->transposh->options->get_enable_footer_scripts()) . '/> '.
|
471 |
+
'Push transposh scripts to footer of page instead of header, makes pages load faster. '.
|
472 |
+
'Requires that your theme should have proper footer support.';
|
473 |
}
|
474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
/**
|
476 |
* Insert the option to enable/disable language auto-detection
|
477 |
* @since 0.3.8 */
|
478 |
+
echo '<h4>Auto detect language for users</h4>';
|
479 |
+
echo '<input type="checkbox" value="1" name="'.ENABLE_DETECT_LANG_AND_REDIRECT.'" '. $this->checked($this->transposh->options->get_enable_detect_language()) . '/> '.
|
480 |
'This enables auto detection of language used by the user as defined in the ACCEPT_LANGUAGES they send. '.
|
481 |
'This will redirect the first page accessed in the session to the same page with the detected language.';
|
482 |
|
483 |
+
/* WIP2
|
|
|
|
|
|
|
|
|
|
|
484 |
echo '<a href="http://transposh.org/services/index.php?flags='.$flags.'">Gen sprites</a>';*/
|
485 |
}
|
486 |
|
wp/transposh_ajax.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Copyright © 2009 Transposh Team (website : http://transposh.org)
|
3 |
+
*
|
4 |
+
* This program is free software; you can redistribute it and/or modify
|
5 |
+
* it under the terms of the GNU General Public License as published by
|
6 |
+
* the Free Software Foundation; either version 2 of the License, or
|
7 |
+
* (at your option) any later version.
|
8 |
+
*
|
9 |
+
* This program is distributed in the hope that it will be useful,
|
10 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
+
* GNU General Public License for more details.
|
13 |
+
*
|
14 |
+
* You should have received a copy of the GNU General Public License
|
15 |
+
* along with this program; if not, write to the Free Software
|
16 |
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
+
*/
|
18 |
+
|
19 |
+
/*
|
20 |
+
* This file handles various AJAX needs of our plugin
|
21 |
+
*/
|
22 |
+
// we need wordpress and us...
|
23 |
+
require_once('../../../../wp-load.php');
|
24 |
+
|
25 |
+
// the case of posted translation
|
26 |
+
if (isset($_POST['translation_posted'])) {
|
27 |
+
if ($_POST['translation_posted'] == 2) {
|
28 |
+
$my_transposh_plugin->database->update_translation_new();
|
29 |
+
}
|
30 |
+
else {
|
31 |
+
$my_transposh_plugin->database->update_translation();
|
32 |
+
}
|
33 |
+
}
|
34 |
+
// getting translation history
|
35 |
+
elseif (isset($_GET['tr_token_hist'])) {
|
36 |
+
$my_transposh_plugin->database->get_translation_history($_GET['tr_token_hist'], $_GET['lang']);
|
37 |
+
}
|
38 |
+
// getting phrases of a post (if we are in admin)
|
39 |
+
elseif (isset($_GET['tr_phrases_post'])) {
|
40 |
+
$my_transposh_plugin->postpublish->get_post_phrases($_GET['post']);
|
41 |
+
}
|
42 |
+
// set the cookie with ajax, no redirect needed
|
43 |
+
elseif (isset($_GET['tr_cookie'])) {
|
44 |
+
setcookie('TR_LNG',get_language_from_url($_SERVER['HTTP_REFERER'], $my_transposh_plugin->home_url),time()+90*24*60*60,COOKIEPATH,COOKIE_DOMAIN);
|
45 |
+
|
46 |
+
}
|
47 |
+
// Set our cookie and return (if no js works - or we are in the default language)
|
48 |
+
elseif (isset($_GET['tr_cookie_bck'])) {
|
49 |
+
setcookie('TR_LNG',get_language_from_url($_SERVER['HTTP_REFERER'], $my_transposh_plugin->home_url),time()+90*24*60*60,COOKIEPATH,COOKIE_DOMAIN);
|
50 |
+
wp_redirect($_SERVER['HTTP_REFERER']);
|
51 |
+
}
|
52 |
+
?>
|
transposh_db.php → wp/transposh_db.php
RENAMED
@@ -23,10 +23,6 @@
|
|
23 |
*
|
24 |
*/
|
25 |
|
26 |
-
|
27 |
-
require_once("core/constants.php");
|
28 |
-
require_once("core/utils.php");
|
29 |
-
|
30 |
//
|
31 |
//Constants
|
32 |
//
|
23 |
*
|
24 |
*/
|
25 |
|
|
|
|
|
|
|
|
|
26 |
//
|
27 |
//Constants
|
28 |
//
|
transposh_options.php → wp/transposh_options.php
RENAMED
@@ -40,6 +40,8 @@ define("OLD_ENABLE_CSS_FLAGS", "transposh_enable_css_flags");
|
|
40 |
define("OLD_DEFAULT_LANG", "transposh_default_language");
|
41 |
//Option defining transposh widget appearance
|
42 |
define("OLD_WIDGET_TRANSPOSH", "transposh_widget");
|
|
|
|
|
43 |
|
44 |
//defines are used to avoid typos
|
45 |
//Option defining whether anonymous translation is allowed.
|
@@ -48,6 +50,8 @@ define("ANONYMOUS_TRANSLATION", "allow_anonymous_translation");
|
|
48 |
define("VIEWABLE_LANGS", "viewable_languages");
|
49 |
//Option defining the list of currentlly editable languages
|
50 |
define("EDITABLE_LANGS", "editable_languages");
|
|
|
|
|
51 |
//Option to enable/disable auto translation
|
52 |
define("ENABLE_AUTO_TRANSLATE", "enable_autotranslate");
|
53 |
//Option to enable/disable auto translation
|
@@ -64,8 +68,6 @@ define("ENABLE_SEARCH_TRANSLATE", "enable_search_translate");
|
|
64 |
define("ENABLE_PERMALINKS", "enable_permalinks");
|
65 |
//Option to enable/disable footer scripts (2.8 and up)
|
66 |
define("ENABLE_FOOTER_SCRIPTS", "enable_footer_scripts");
|
67 |
-
//Option to enable/disable footer scripts (2.8 and up) -- TODO should go away
|
68 |
-
define("ALTERNATE_POST", "alternate_post_method");
|
69 |
//Option to enable detect and redirect language @since 0.3.8
|
70 |
define("ENABLE_DETECT_LANG_AND_REDIRECT", "enable_detect_redirect");
|
71 |
//Option defining the default language
|
@@ -136,9 +138,12 @@ class transposh_plugin_options {
|
|
136 |
unset($this->options['enable_css_flags']);
|
137 |
|
138 |
}
|
|
|
|
|
139 |
}
|
140 |
|
141 |
function get_anonymous_translation() {
|
|
|
142 |
return $this->options[ANONYMOUS_TRANSLATION];
|
143 |
}
|
144 |
|
@@ -150,6 +155,17 @@ class transposh_plugin_options {
|
|
150 |
return $this->options[EDITABLE_LANGS];
|
151 |
}
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
function get_widget_progressbar() {
|
154 |
return $this->options[WIDGET_PROGRESSBAR];
|
155 |
}
|
@@ -178,10 +194,6 @@ class transposh_plugin_options {
|
|
178 |
return $this->options[ENABLE_FOOTER_SCRIPTS];
|
179 |
}
|
180 |
|
181 |
-
function get_alternate_post() {
|
182 |
-
return $this->options[ALTERNATE_POST];
|
183 |
-
}
|
184 |
-
|
185 |
function get_enable_detect_language() {
|
186 |
return $this->options[ENABLE_DETECT_LANG_AND_REDIRECT];
|
187 |
}
|
@@ -213,14 +225,17 @@ class transposh_plugin_options {
|
|
213 |
}
|
214 |
|
215 |
/**
|
216 |
-
* Gets the default language setting, i.e. the source language which
|
217 |
-
* should not be translated.
|
218 |
* @return string Default language
|
219 |
*/
|
220 |
function get_default_language() {
|
221 |
$default = $this->options[DEFAULT_LANG];
|
222 |
if(!$GLOBALS['languages'][$default]) {
|
223 |
-
$
|
|
|
|
|
|
|
|
|
224 |
}
|
225 |
return $default;
|
226 |
}
|
@@ -250,6 +265,10 @@ class transposh_plugin_options {
|
|
250 |
$this->set_value($val, $this->options[EDITABLE_LANGS]);
|
251 |
}
|
252 |
|
|
|
|
|
|
|
|
|
253 |
function set_widget_progressbar($val) {
|
254 |
$val = ($val) ? 1 : 0;
|
255 |
$this->set_value($val, $this->options[WIDGET_PROGRESSBAR]);
|
@@ -279,10 +298,6 @@ class transposh_plugin_options {
|
|
279 |
$this->set_value($val, $this->options[ENABLE_PERMALINKS]);
|
280 |
}
|
281 |
|
282 |
-
function set_alternate_post($val) {
|
283 |
-
$this->set_value($val,$this->options[ALTERNATE_POST]);
|
284 |
-
}
|
285 |
-
|
286 |
function set_enable_detect_language($val) {
|
287 |
$val = ($val) ? 1 : 0;
|
288 |
$this->set_value($val,$this->options[ENABLE_DETECT_LANG_AND_REDIRECT]);
|
40 |
define("OLD_DEFAULT_LANG", "transposh_default_language");
|
41 |
//Option defining transposh widget appearance
|
42 |
define("OLD_WIDGET_TRANSPOSH", "transposh_widget");
|
43 |
+
//Option to enable/disable footer scripts (2.8 and up) -- @deprecated 0.3.9
|
44 |
+
define("OLD_ALTERNATE_POST", "alternate_post_method");
|
45 |
|
46 |
//defines are used to avoid typos
|
47 |
//Option defining whether anonymous translation is allowed.
|
50 |
define("VIEWABLE_LANGS", "viewable_languages");
|
51 |
//Option defining the list of currentlly editable languages
|
52 |
define("EDITABLE_LANGS", "editable_languages");
|
53 |
+
//Option defining the ordered list of languages @since 0.3.9
|
54 |
+
define("SORTED_LANGS", "sorted_languages");
|
55 |
//Option to enable/disable auto translation
|
56 |
define("ENABLE_AUTO_TRANSLATE", "enable_autotranslate");
|
57 |
//Option to enable/disable auto translation
|
68 |
define("ENABLE_PERMALINKS", "enable_permalinks");
|
69 |
//Option to enable/disable footer scripts (2.8 and up)
|
70 |
define("ENABLE_FOOTER_SCRIPTS", "enable_footer_scripts");
|
|
|
|
|
71 |
//Option to enable detect and redirect language @since 0.3.8
|
72 |
define("ENABLE_DETECT_LANG_AND_REDIRECT", "enable_detect_redirect");
|
73 |
//Option defining the default language
|
138 |
unset($this->options['enable_css_flags']);
|
139 |
|
140 |
}
|
141 |
+
// this has deprecated at 0.3.9
|
142 |
+
unset ($this->options[OLD_ALTERNATE_POST]);
|
143 |
}
|
144 |
|
145 |
function get_anonymous_translation() {
|
146 |
+
if (!isset($this->options[ANONYMOUS_TRANSLATION])) return 1; // default is true
|
147 |
return $this->options[ANONYMOUS_TRANSLATION];
|
148 |
}
|
149 |
|
155 |
return $this->options[EDITABLE_LANGS];
|
156 |
}
|
157 |
|
158 |
+
/**
|
159 |
+
* Get a user sorted language list
|
160 |
+
* @since 0.3.9
|
161 |
+
* @return array sorted list of languages, pointing to names and flags
|
162 |
+
*/
|
163 |
+
function get_sorted_langs() {
|
164 |
+
if (isset($this->options[SORTED_LANGS]))
|
165 |
+
return array_merge(array_flip(explode(",",$this->options[SORTED_LANGS])),$GLOBALS['languages']);
|
166 |
+
return $GLOBALS['languages'];
|
167 |
+
}
|
168 |
+
|
169 |
function get_widget_progressbar() {
|
170 |
return $this->options[WIDGET_PROGRESSBAR];
|
171 |
}
|
194 |
return $this->options[ENABLE_FOOTER_SCRIPTS];
|
195 |
}
|
196 |
|
|
|
|
|
|
|
|
|
197 |
function get_enable_detect_language() {
|
198 |
return $this->options[ENABLE_DETECT_LANG_AND_REDIRECT];
|
199 |
}
|
225 |
}
|
226 |
|
227 |
/**
|
228 |
+
* Gets the default language setting, i.e. the source language which normally should not be translated.
|
|
|
229 |
* @return string Default language
|
230 |
*/
|
231 |
function get_default_language() {
|
232 |
$default = $this->options[DEFAULT_LANG];
|
233 |
if(!$GLOBALS['languages'][$default]) {
|
234 |
+
if (defined('WPLANG') && $GLOBALS['languages'][WPLANG]) {
|
235 |
+
$default = WPLANG;
|
236 |
+
} else {
|
237 |
+
$default = "en";
|
238 |
+
}
|
239 |
}
|
240 |
return $default;
|
241 |
}
|
265 |
$this->set_value($val, $this->options[EDITABLE_LANGS]);
|
266 |
}
|
267 |
|
268 |
+
function set_sorted_langs($val) {
|
269 |
+
$this->set_value($val, $this->options[SORTED_LANGS]);
|
270 |
+
}
|
271 |
+
|
272 |
function set_widget_progressbar($val) {
|
273 |
$val = ($val) ? 1 : 0;
|
274 |
$this->set_value($val, $this->options[WIDGET_PROGRESSBAR]);
|
298 |
$this->set_value($val, $this->options[ENABLE_PERMALINKS]);
|
299 |
}
|
300 |
|
|
|
|
|
|
|
|
|
301 |
function set_enable_detect_language($val) {
|
302 |
$val = ($val) ? 1 : 0;
|
303 |
$this->set_value($val,$this->options[ENABLE_DETECT_LANG_AND_REDIRECT]);
|
transposh_postpublish.php → wp/transposh_postpublish.php
RENAMED
@@ -21,9 +21,6 @@
|
|
21 |
* Provides the side widget in the page/edit pages which will do translations
|
22 |
*/
|
23 |
|
24 |
-
|
25 |
-
require_once("core/jsonwrapper/jsonwrapper.php");
|
26 |
-
|
27 |
/**
|
28 |
* class that makes changed to the edit page and post page, adding our change to the side ba
|
29 |
*/
|
21 |
* Provides the side widget in the page/edit pages which will do translations
|
22 |
*/
|
23 |
|
|
|
|
|
|
|
24 |
/**
|
25 |
* class that makes changed to the edit page and post page, adding our change to the side ba
|
26 |
*/
|
transposh_widget.php → wp/transposh_widget.php
RENAMED
@@ -21,11 +21,6 @@
|
|
21 |
* mode.
|
22 |
*/
|
23 |
|
24 |
-
require_once("core/constants.php");
|
25 |
-
require_once("core/utils.php");
|
26 |
-
require_once("transposh.php");
|
27 |
-
|
28 |
-
|
29 |
//class that reperesent the complete plugin
|
30 |
class transposh_plugin_widget {
|
31 |
/** @var transposh_plugin Container class */
|
@@ -138,8 +133,8 @@ class transposh_plugin_widget {
|
|
138 |
echo "<div class=\"" . NO_TRANSLATE_CLASS . " transposh_flags\" >";
|
139 |
if ($this->transposh->options->get_widget_in_list()) echo "<ul>";
|
140 |
|
141 |
-
foreach($
|
142 |
-
list($language,$flag) = explode (",",$
|
143 |
|
144 |
//Only show languages which are viewable or (editable and the user is a translator)
|
145 |
if($this->transposh->options->is_viewable_language($code) ||
|
@@ -179,8 +174,8 @@ class transposh_plugin_widget {
|
|
179 |
echo "<select name=\"lang\" id=\"lang\" onchange=\"Javascript:this.form.submit();\">";
|
180 |
echo "<option value=\"none\">[Language]</option>";
|
181 |
|
182 |
-
foreach($
|
183 |
-
list($language,$flag) = explode (",",$
|
184 |
|
185 |
//Only show languages which are viewable or (editable and the user is a translator)
|
186 |
if($this->transposh->options->is_viewable_language($code) ||
|
@@ -202,7 +197,7 @@ class transposh_plugin_widget {
|
|
202 |
if ($this->transposh->js_included) {
|
203 |
echo '<a href="#" id="'.SPAN_PREFIX.'setdeflang" onClick="return false;">Set as default language</a><br/>';
|
204 |
} else {
|
205 |
-
echo '<a href="'.$this->transposh->
|
206 |
}
|
207 |
}
|
208 |
}
|
21 |
* mode.
|
22 |
*/
|
23 |
|
|
|
|
|
|
|
|
|
|
|
24 |
//class that reperesent the complete plugin
|
25 |
class transposh_plugin_widget {
|
26 |
/** @var transposh_plugin Container class */
|
133 |
echo "<div class=\"" . NO_TRANSLATE_CLASS . " transposh_flags\" >";
|
134 |
if ($this->transposh->options->get_widget_in_list()) echo "<ul>";
|
135 |
|
136 |
+
foreach($this->transposh->options->get_sorted_langs() as $code => $langrecord) {
|
137 |
+
list ($langname,$language,$flag) = explode (",",$langrecord);
|
138 |
|
139 |
//Only show languages which are viewable or (editable and the user is a translator)
|
140 |
if($this->transposh->options->is_viewable_language($code) ||
|
174 |
echo "<select name=\"lang\" id=\"lang\" onchange=\"Javascript:this.form.submit();\">";
|
175 |
echo "<option value=\"none\">[Language]</option>";
|
176 |
|
177 |
+
foreach($this->transposh->options->get_sorted_langs() as $code => $langrecord) {
|
178 |
+
list ($langname,$language,$flag) = explode (",",$langrecord);
|
179 |
|
180 |
//Only show languages which are viewable or (editable and the user is a translator)
|
181 |
if($this->transposh->options->is_viewable_language($code) ||
|
197 |
if ($this->transposh->js_included) {
|
198 |
echo '<a href="#" id="'.SPAN_PREFIX.'setdeflang" onClick="return false;">Set as default language</a><br/>';
|
199 |
} else {
|
200 |
+
echo '<a href="'.$this->transposh->post_url.'?tr_cookie_bck">Set as default language</a><br/>';
|
201 |
}
|
202 |
}
|
203 |
}
|