-
1. Re: JS Display international characters
Marijan Tompa Aug 20, 2010 5:17 AM (in response to John.Kordas) -
2. Re: JS Display international characters
John.Kordas Aug 20, 2010 5:28 AM (in response to Marijan Tompa)Hi tomaxxi
I've tried it in CS5 and it works fine. The changes I need to make are for CS3. So if it works in CS5 internationl characters are ok?
-
3. Re: JS Display international characters
Marijan Tompa Aug 20, 2010 5:28 AM (in response to John.Kordas)When I start the script this error shows up:
I'm using Win7 64-bit / InDesign CS5 US English
--
tomaxxi
-
4. Re: JS Display international characters
John.Kordas Aug 20, 2010 5:58 AM (in response to Marijan Tompa)That's strange I'll have to run some more trials on Monday again.
with(myDocument.documentPreferences){
pageHeight = "297mm";
pageWidth = "210mm";
//pageOrientation = PageOrientation.landscape;
//pagesPerDocument = 16;
} <---------------line 25.Thanks again tomaxxi I'll look into this.
-
5. Re: JS Display international characters
Marijan Tompa Aug 20, 2010 6:06 AM (in response to John.Kordas)Not problem.
This code works just fine.
Maybe try not to use with statement.
--
tomaxxi
-
6. Re: JS Display international characters
[Jongware] Aug 20, 2010 6:31 AM (in response to John.Kordas)To insert any other character into Javascript strings than plain A..Z, you can always safely use Unicode notation. You need to look up the Unicode values of the characters you want to insert, but fortunately InDesign can help you with that: the Glyphs panel shows the Unicode value for any character if you hover the mouse over it, andyou can copy some text from the web, paste it into InDesign, then select each character in turn and check the Info panel.
Insert the Unicode values into your javascript string like this: "\u0000" where the zeros should be replaced with all four Unicode digits in hex notation (which is nothing more complicated than "that's exactly what InDesign is showing you in the Info panel").
For instance, "Jongware" appears on Russian web sites as something like this: Дзонгшаре
As a Javascript string this would be "\u0414\u0437\u043e\u043d\u0433\u0448\u0430\u0440\u0435".
-
7. Re: JS Display international characters
Kasyan Servetsky Aug 20, 2010 9:02 AM (in response to [Jongware])For instance, "Jongware" appears on Russian web sites as something like this: Дзонгшаре
No, it should be either Джонгваре (transcription) or Джонгвэа (transliteration).
As to Unicode notation, theres no need to use it with CS3/4/5 — I just type text in Russian and it works perfectly. You have to add Russian in Input Menu (Mac) or in Languages and Regional Settings Panel (Windows) for this.
The only issue I know about are Submenus: never name them in Russian on Mac.
Kasyan
-
8. Re: JS Display international characters
[Jongware] Aug 20, 2010 1:06 PM (in response to Kasyan Servetsky)Hi Kasyan! You are correct: I couldn't find my example anymore because I didn't recall in which discussion I was mentioned With your transcription I found it again -- "... а точнееп понять все то, что изложено на Джонгваре..."
-
9. Re: JS Display international characters
John.Kordas Aug 29, 2010 6:37 PM (in response to [Jongware])
Thanks Jongware and Kasyan,I haven't been able to get to this until now but I've added Russian to my keyboard languages and then I type out Jongware I get Ощтпцфку.
If I've done this correct then the following code would determine that my default app language is Russian and use case 1279480437: correct?
switch (app.locale)
{
case 1279477102:
var myLetters = "Jongware";
break;
case 1279480437:
var myLetters = "Ощтпцфку";
break;
default:
var myLetters = "Jongware";
} -
10. Re: JS Display international characters
Marc Autret Aug 30, 2010 12:14 AM (in response to John.Kordas)Hi John,
Just for your information, YALT is a free snippet to easily manage multilingual InDesign JS scripts. It autodetects the app.locale and allows you to provide a complete translation table. It supports Unicode notation and %N placeholders:
http://www.indiscripts.com/category/projects/YALT
@+
Marc
-
11. Re: JS Display international characters
Kasyan Servetsky Aug 30, 2010 1:04 AM (in response to John.Kordas)Hi John,
Here is a brief description how I make my multilingual scripts:
I add the following line to my start up script
app.locale = 'ru';
This makes English copy of InDesign use Russian locale (after restart of course) util the end of session.
Then I use the following syntax to make my messages in dialogs, alerts, etc. bilingual:
err(localize({en: 'No documents are open. Please open a document and try again.', ru: 'Не открыт ни один документ, откройте файл и попробуйте снова.'}));You can also quickly (without restarting InDesign) change locale from ESTK by running app.locale = 'en'; either as one line script or type it in console and press Return/Enter — just use two letter code for the language you want to switch.
Regards,
Kasyan
-
12. Re: JS Display international characters
John.Kordas Aug 30, 2010 6:44 AM (in response to Kasyan Servetsky)Thanks Marc and Kaysan,
For some reason Kaysan I get an error message telling
Error Number: 30474
Error String: 'local' is a read only property.
Line:1
Source: app.locale='ru';
Marc I'm looking through your snippet as we speak, much appreciated to you both.
Cheers, John.
-
13. Re: JS Display international characters
Kasyan Servetsky Aug 30, 2010 12:35 PM (in response to John.Kordas)John,
I am sorry — my memory let me down , it should have been:
$.locale = 'ru';
Kasyan
-
14. Re: JS Display international characters
John.Kordas Aug 30, 2010 11:09 PM (in response to Kasyan Servetsky)Hi all,
OK I'm hoping this will work and it will mean I will only need to add one line and it should work for everyone.
Could anyone running ESTK with a language other than English please run this and tell me if they get the correct letters returned in the correct language?
alert(String.fromCharCode(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,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,91,92,93,94,95,96,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))
I get this.
Is there any reason why I should not take this approach?
Cheers, John.
-
15. Re: JS Display international characters
Marijan Tompa Aug 30, 2010 11:47 PM (in response to John.Kordas) -
16. Re: JS Display international characters
Kasyan Servetsky Aug 31, 2010 1:43 AM (in response to John.Kordas)Is there any reason why I should not take this approach?
Why don't you want to type Russian characters on the keyboard, or use Character Map (or similar) application to select and copy characters, and paste them into your alert messages? This approach works for me for any language: English, Russian, Greece, etc., and for both Mac and PC. You don't have to change locale to display these characters and I am sure it should work for any language version of InDesign.
What happens if you run the following line?
alert("English Русский");Do you see the second word in Russian?
Kasyan
-
17. Re: JS Display international characters
[Jongware] Aug 31, 2010 2:36 AM (in response to John.Kordas)In any other language and/or script the dialog would look exactly the same -- the Unicode character set has fixed codes per letter, so value #65 will always give you an 'A'. Your script is totally equivalent to
alert ("ABCDEF..."etc etc");
This will show a selection of Greek and Cyrillic glyphs:
alert (String.fromCharCode('G'.charCodeAt(0), 58, 0x3b1, 0x3b2, 947, 948, 0x3c9, 47, 'R'.charCodeAt(0), 58, 0x420,0x443,0x441));
but it is (or should be) totally equivalent to
alert ("G:αβγδω/R:Рус");
regardless of your current locale setting.
-
18. Re: JS Display international characters
John.Kordas Aug 31, 2010 4:37 AM (in response to [Jongware])Thanks Kasyan and Jongware,
I was hoping that the Unicode approach might allow me to only have to enter one string of letter and not enter all languages.
But following Kasyan's example I was able to get both the Russian and Greek string to display so I think this will be the way forward.
Using this in my startup scripts
$.locale = 'ru';
The following code
var myLetters = (localize({
en: 'ABCDESFGHIJKLMNOPQRTSUVWXYZ.....%^&*()',
ru: 'ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ......%:?*()',
el: 'ΑΒΨΔΕΦΓΗΙΞΚΛΜΝΟΠ;ΡΣΤΘΩςΧΥΖ......%^&*()'
}));
alert(myLetters);returns
Cheers,
John.
-
19. Re: JS Display international characters
[Jongware] Aug 31, 2010 4:44 AM (in response to John.Kordas)Поздравляем!
-
20. Re: JS Display international characters
John.Kordas Aug 31, 2010 5:05 AM (in response to [Jongware])Спасибо
Any suggestions on which languages to include. Looking at my Character Map French and Italian look the same as English.
John.
-
21. Re: JS Display international characters
[Jongware] Aug 31, 2010 5:29 AM (in response to John.Kordas)Although your working sample displays three different scripts (Latin; Greek; Cyrillic), it's of No Importance At All. It's the different languages that count.
So for French and Italian, you would add:
var myLetters = (localize({ en: 'ABCDESFGHIJKLMNOPQRTSUVWXYZ.....%^&*()', ru: 'ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ......%:?*()', el: 'ΑΒΨΔΕΦΓΗΙΞΚΛΜΝΟΠ;ΡΣΤΘΩςΧΥΖ......%^&*()', fr:'Une message simple : ça marche!', it:'Non ho idea di come dire qualcosa di utile in italiano' }));You appear to think your myLetters variable ought to hold the allowable set of characters per language. Well ... no. Translating something does not (ever, if I'm correct) amount to transposing each character into another.
Take, for example, the Greek word for Greece. The alternative English name Hellas comes from Ελλάδα, but if you would somehow translate it one character at a time, you get "Ellada".
You should think of myLetters as a message instead. Suppose your script may display an alert
alert ("Bad input. You'll have to start all over again!");
then you can make a list for this message alone:
var badInputMsg = (localise({
en:"Bad input. You'll have to start all over again!",
el:"Λάθος εισροών. Θα πρέπει να ξεκινήσει ξανά από την αρχή!",
es:"Entrada incorrecta. Vas a tener que empezar todo de nuevo!",
}));
etc., for every language you care to include, and for every message and text string you add to your script as well.
-
22. Re: JS Display international characters
John.Kordas Aug 31, 2010 6:22 AM (in response to [Jongware])Thanks Jongware,
So instead of displaying all characers in the catalogue would this be better:
var myLetters = (localize({
en: 'the quick brown fox jumps over the lazy dog \nABCDESFGHIJKLMNOPQRTSUVWXYZ.....%^&*()',
ru: 'быстрый булок, лентяй \nФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ......%:?*()',
el: 'Η σύσκεψη θα γίνει κατά τη διάρκεια της αλεπούς Lazy Dog \nΑΒΨΔΕΦΓΗΙΞΚΛΜΝΟΠ;ΡΣΤΘΩςΧΥΖ......%^&*()',
fr:'les sauts rapide renard brun sur le chien paresseux \nABCDESFGHIJKLMNOPQRTSUVWXYZ.....%^&*()',
it:'il mattino ha brown fox sul cane pigro \nABCDESFGHIJKLMNOPQRTSUVWXYZ.....%^&*()'
}));








