smartquotes.js icon indicating copy to clipboard operation
smartquotes.js copied to clipboard

Add support for other languages

Open k-nut opened this issue 11 years ago • 11 comments

Other languages such as German and French use different ways to quote. I implemented a basic mechanism to adapt to the language of the document which is set via <html lang='de'>. You can try it out with the commits from my fork. It seems to work for German but the French is getting mixed up by the 'em in one of the first paragraphs in the badger.html. Would you like to merge this into your version once it is working?

k-nut avatar Feb 03 '14 09:02 k-nut

Great idea! I'd definitely would like to merge it in -- multi-language support would be super useful.

kellym avatar Feb 03 '14 14:02 kellym

I found out that in order to solve the problem mentioned there needs to be a dedicated way to handle apostrophes for abbreviations. This is not a problem in English since you just use the same symbol that you use for a single quotation mark. This is not the case in German and French though. So there needs to be a way to properly find those. Any ideas?

k-nut avatar Feb 04 '14 18:02 k-nut

:+1:

cedricmay avatar Feb 24 '15 16:02 cedricmay

@k-nut: I appreciate that you're probably not interested in doing this any more, but if you are (or if anyone else wants to have a go), I think a state machine would be useful here. Unfortunately, most libraries to do that in JS are bigger than this library! Still, I think it would be a useful feature—possibly in another file (smartquotes.js and smartquotes.multilang.js`?).

callumacrae avatar Feb 25 '15 11:02 callumacrae

Hey @callumacrae I would sure love to finish this. I got the German version running after all and would at least like to include that. How do you think a state machine could be useful here? And splitting this into another file for multilang support seems like a good idea!

k-nut avatar Mar 02 '15 19:03 k-nut

I'm not sure, but if you gave me a specific case where regular expressions wouldn't do the trick, I could try to explain an example.

callumacrae avatar Mar 02 '15 19:03 callumacrae

Well one problem for example are years like '93. They are replaced by the character that also is the beginning single quote () in English. In German & French the beginning single quote is another character though ()... I guess that this could be worked around with regex as well. It's been quite some time since I last checked the code...

k-nut avatar Mar 02 '15 20:03 k-nut

I see. So de and fr use different characters for quotes and abbreviations, which en uses the same?

I can't see any way around that short of replacing both the start and end quote at the same time. I wonder how other libraries handle this.

callumacrae avatar Mar 02 '15 20:03 callumacrae

As far as I am able to tell that is right. I'm not a language/typography expert though... Good question how the other libraries handle this!

k-nut avatar Mar 02 '15 20:03 k-nut

I can't even find any other libraries that do this!

callumacrae avatar Mar 02 '15 21:03 callumacrae

For reference https://en.wikipedia.org/wiki/Quotation_mark#Summary_table_for_all_languages

j-rieck avatar Apr 10 '15 10:04 j-rieck