Duolingo is the most popular way to learn languages in the world. Best of all, it's 100% free!

https://www.duolingo.com/PatrickSnyder

Bookmarklet to convert x-notation into ĉĝĥĵŝŭĈĜĤĴŜŬ while typing (in any modern browser)

To use

  1. Type in Esperanto <-- Drag this link to your bookmark bar

  2. Click the bookmark while on any website. From then on, it will automatically convert x-notation (cx, gx, hx, jx, sx, ux, Cx, Gx, Hx, Jx, Sx, Ux) into ĉĝĥĵŝŭĈĜĤĴŜŬ while typing (until you reload or leave that page).

If you find that you need to write something like 'ux' for some reason, you can write 'x' first, then go back and put the 'u' in front of it.


Hi all,

I just joined yesterday and started the Esperanto course.

At the bottom of the Basics 1 lesson, I noticed it said, "Note that Duolingo will not convert accented characters entered via the x-system in the answer immediately when typed".

So I created a bookmarklet that does just that. You can use it on any website, and it will convert things like sx to ŝ as you type.

The script stops when you go to a new page, or reload the page.

Tested and working in Chrome, Firefox, Internet Explorer, Opera & Safari.

I'll be using it while I learn Esperanto. I just thought I'd post it here in case anyone else found it useful.

3 years ago

26 Comments


https://www.duolingo.com/PatrickSnyder

Edit 1: redid code

  1. Now changes the letter instantly
  2. Now only changes the letter you type the 'x' next to.
  3. Shorter more efficient code
  4. Added a draggable link making it easier to bookmark

Edit 2:

  1. Added support for Internet Explorer. (It should now work in all modern browsers.)
  2. Added search box functionality (I noticed it wasn't working in Wikipedia's search box. It does now.)

Edit 3:

This was odd, but I actually had to change the script so that the link would work on Duolingo's message board (backslash '\' doesn't seem to be allowed in a link). Now one link works for every browser.


Expanded code for readability:

<pre>javascript:(function(){ var d=document,s=String.fromCharCode,u={C:s(264),c:s(265),G:s(284),g:s(285),H:s(292),h:s(293),J:s(308),j:s(309),S:s(348),s:s(349),U:s(364),u:s(365)}; d.onkeypress=function(e){ if(e.charCode===88||e.charCode===120){ var a=d.activeElement,t=a.type; if(t==='text'||t==='textarea'||t==='search'){ var v=a.value,p=a.selectionStart,c=v.charAt(p-1); if(c.search(/[cghjsuCGHJSU]/)!==-1){ a.value=v.substring(0,p-1)+u[c]+v.substring(p); a.setSelectionRange(p,p); e.preventDefault(); } } } } })(); </pre>
3 years ago

https://www.duolingo.com/ChristianofPeace

Ok, yoŭ are awesome.

Tĥank yoŭ!

3 years ago

https://www.duolingo.com/PatrickSnyder

Thanks for the upvotes and kind words! This is a nice community.

3 years ago

https://www.duolingo.com/LaArakido
LaArakido
  • 25
  • 21
  • 21
  • 21
  • 14
  • 11
  • 10
  • 8
  • 1407

Works great on Safari as well. Thank you very much.

3 years ago

https://www.duolingo.com/PatrickSnyder

Thank you for trying it and letting me know! Safari's now added to the "tested and working" list.

3 years ago

https://www.duolingo.com/EmmanuelBouh
EmmanuelBouh
  • 25
  • 16
  • 12
  • 11
  • 8
  • 6
  • 6
  • 4
  • 4
  • 3
  • 1359

Dankon!

3 years ago

https://www.duolingo.com/GrandApple
GrandApple
  • 18
  • 11
  • 11
  • 9
  • 8
  • 6
  • 5
  • 5
  • 4
  • 3
  • 3
  • 2

We have such talented people on here.

3 years ago

https://www.duolingo.com/Purplegrant

Thanks! That's great.

3 years ago

https://www.duolingo.com/DetErMinNavn
DetErMinNavn
  • 25
  • 14
  • 10
  • 10
  • 10
  • 10
  • 10
  • 10
  • 9
  • 9
  • 7
  • 7
  • 6
  • 6

Thanks!

3 years ago

https://www.duolingo.com/PatrickSnyder

Quick question...

I'm now seeing a few posts where people talk about h-notation. But some are saying there are problems with it. What are the problems?

Are there any valid Esperanto words where 'h' comes immediately after 'c', 'g', 'h', 'j', 's', or 'u'? Or can 'ch' and 'sh' be used in names? Or do all proper nouns become Esperanto-ized?

It would be easy to make this bookmarklet work for h-notation as well, if people wanted that. The one benefit I see is that 'sh' is easier to type than 'sx'. But I also see a problem, where someone may want to type Esperanto mixed with another language like English.

3 years ago

https://www.duolingo.com/LaArakido
LaArakido
  • 25
  • 21
  • 21
  • 21
  • 14
  • 11
  • 10
  • 8
  • 1407

Using the combination with "h" may not be such a good idea. Several Esperanto words have that combination. From Bertilo : "senchava" (making sense) "flughaveno" (airport), "seshora" (six hour (long movie)) to name a few.

Edit: but of course if some prefer the "h" solution I will not stand in their way. Personally I prefer the "x" though.

3 years ago

https://www.duolingo.com/PatrickSnyder

Thank you! That's exactly what I was wondering about.

Making it work would for h-notation wouldn't be as easy then, since it would have to check for valid words against a dictionary. X-notation seems superior since it's not ambiguous.

Thanks again!

3 years ago

https://www.duolingo.com/bajanisto
bajanisto
  • 19
  • 11
  • 10
  • 7

I use a comma (,) on my keyboard, so

  • , + c => ĉ
  • , + g => ĝ
  • , + h => ĥ
  • , + j => ĵ
  • , + s => ŝ
  • , + u => ŭ

Does that would be possible in your system?

3 years ago

https://www.duolingo.com/PatrickSnyder

With the following bookmarklet, if you type one of these letters (cghjsuCGHJSU) after a comma, the comma is replaced with the corresponding letter (ĉĝĥĵŝŭĈĜĤĴŜŬ).

bajanisto style <-- Drag this to your bookmark bar.

That's a clever way of doing it, since there's normally a space after a comma! Is it common?

3 years ago

https://www.duolingo.com/bajanisto
bajanisto
  • 19
  • 11
  • 10
  • 7

Thanks! — It works well!

Yes, a space is very common.

3 years ago

https://www.duolingo.com/PatrickSnyder

Pardonu mi. Mi volas demandi: Ĉu la metodo de uzi komo, fari literojn kun diakritoj, estas komuna?

Kaj dankon! Mi feliĉas, ke vi povas uzi ĝin!

3 years ago

https://www.duolingo.com/bajanisto
bajanisto
  • 19
  • 11
  • 10
  • 7

Miakomprene, tiu metodo (kun la komo) ne estas tre ofte uzata, kvankam en la programetoj EK kaj Tajpi estas tiu eblo. Mi ja komencis uzi ĝin en mia propra ÅUIOGX-klavaro antaŭ 6 jaroj. La ÅUIOGX-klavaro (finne: ÅUIOGX-näppäimistö) estas optimizita por la finna kaj Esperanto.

Miaopinie, la metodo estas tre bona, ĉar ĝi ebligas uzi ambaŭ manojn pro la (bona) situo de la komo sur klavaroj.

3 years ago

https://www.duolingo.com/AmericanBull

Thank you very much for this! :) I did notice that it doesn't seem to work on the Lernu site.

3 years ago

https://www.duolingo.com/PatrickSnyder

Hi! Thank you for trying it!

I made an account on Lernu to try this and I see what you mean. Looking at their code, it's a very old style of writing webpages; like 15 years old. We don't write pages like that anymore.

  1. Whenever you click the "next" arrow or "Sendu", it loads a completely new HTML page. For security reasons, JavaScript is tied to the page it's run on. So each time it loads a new page, the script stops and you have to run a new one. If I could directly update their site, I could include this functionality, no problem. But with a bookmarklet, it means you have to click it again for each new question (HTML page).

  2. The dictionary (vortaro) is also a separate HTML page in a little frame, so the bookmarklet wasn't seeing it. This page also reloads with each new question.

I've added code to make the dictionary work.

Type on Lernu <-- Drag this to your bookmark bar.

But there's nothing I can do about the page changing each question. If you want to use this bookmarklet on a question, you have to click it each time.

3 years ago

https://www.duolingo.com/AmericanBull

When using the "Type on Lernu" booklet mark, and then typing in the the Lernu Dictionary field, hitting Enter no longer seems to send the text to be translated, and requires a mouse click on "Ek!". Not sure if that's something that can be fixed on your end, but just something I noticed.

3 years ago

https://www.duolingo.com/PatrickSnyder

Hi! Thanks for pointing that out! I added a little more, and now hitting 'Enter' should work.

I updated the link. Just delete the old bookmark and drag 'Type on Lernu' back up again.

3 years ago

https://www.duolingo.com/Drew956
Drew956
  • 14
  • 12
  • 9
  • 8
  • 4
  • 4
  • 2
  • 2

Wow ĉu ĝi estas ĉi bonege? Jes, ĝi vere estas! Ĝi tute funkcias! Bonege! Mi amas vin! Koran dankon! Lol. Ĝojege mi ĉeestis la novaĵejojn kaj lanĉis miajn planojn kun ŝipoj da aŭstraliaj akvoj! Ĥorloĝo (Mi ne certas ĉu la antaŭa vorto estas vere E-a vorto, sed eble ĝi estas..?) Ĵus nun mi uzas vian esperantilon, kaj mi tre ŝatas ĝin. Dankon.

3 years ago

https://www.duolingo.com/PatrickSnyder

Dankon! Mi feliĉas, ke vi uzas ĝin!

3 years ago

https://www.duolingo.com/LytjeDk
LytjeDk
  • 21
  • 15
  • 7
  • 6
  • 4
  • 3
  • 2
  • 57

Tre stranga. Ĉi tie funkcias tute bone, sed en gmail ne funkcias. Ĉu mi faras io erare? Aŭ ĉu ne funkcias por gmail?

3 years ago

https://www.duolingo.com/PatrickSnyder

Mi bedaŭras. Ĝi ne funkcias en gmail. Gmail uzas alia stilo de fenestreto: "contentEditable". Ankaŭ, gmail ne permesas ĝin vidi kiu klavo estis premita. Mi ne scias kiel ripari ĝin.

3 years ago

https://www.duolingo.com/uosuaq

Thanks! I wanted to make a bookmarklet like this myself but my Javascript abilities just weren't up to the task. This is great.

3 years ago