QuBiT / cucumber-netbeans-plugin

Plugin / Module which allow Syntax Highlighting and many more in NetBeans with .feature Files
MIT License
50 stars 19 forks source link

Language REQUEST: ALL OF THEM #22

Closed aslakhellesoy closed 14 years ago

aslakhellesoy commented 14 years ago

I've just written up a page with some examples that shows how you can easily add support for all of the 40 i18n languages:

http://wiki.github.com/aslakhellesoy/gherkin/tool-support

It should be generated, not hand written.

QuBiT commented 14 years ago

Hi, thanks for the link but there is one major problem (if you could solve that, support for all is then not a big deal)

I tried to change my feature.nbs file so that it includes:


TOKEN:feature_keywords:('기능'|'機能'|'功能'|'フィーチャ'|'خاصية'|'תכונה'|'Функционалност'|'Функционал'|'Особина'|'Могућност'|'Özellik'|'Właściwość'|'Tính năng'|'Savybė'|'Požiadavka'|'Požadavek'|'Osobina'|'Ominaisuus'|'Omadus'|'OH HAI'|'Mogućnost'|'Mogucnost'|'Jellemző'|'Fīča'|'Funzionalità'|'Funktionalität'|'Funkcionalnost'|'Funkcionalitāte'|'Funcționalitate'|'Functionaliteit'|'Functionalitate'|'Funcionalitat'|'Funcionalidade'|'Fonctionnalité'|'Fitur'|'Feature'|'Egenskap'|'Egenskab'|'Crikey'|'Característica'|'Arwedd')
# SCENARIO, BACKGROUND, ...
TOKEN:feature_element_keywords:('시나리오 개요'|'시나리오'|'배경'|'背景'|'場景大綱'|'場景'|'场景大纲'|'场景'|'劇本大綱'|'劇本'|'テンプレ'|'シナリオテンプレート'|'シナリオテンプレ'|'シナリオアウトライン'|'シナリオ'|'سيناريو مخطط'|'سيناريو'|'الخلفية'|'תרחיש'|'תבנית תרחיש'|'רקע'|'Тарих'|'Сценарио'|'Сценарий структураси'|'Сценарий'|'Структура сценарија'|'Структура сценария'|'Скица'|'Рамка на сценарий'|'Пример'|'Предыстория'|'Предистория'|'Позадина'|'Основа'|'Концепт'|'Контекст'|'Założenia'|'Tình huống'|'Tausta'|'Taust'|'Tapausaihio'|'Tapaus'|'Szenariogrundriss'|'Szenario'|'Szablon scenariusza'|'Stsenaarium'|'Struktura scenarija'|'Skica'|'Skenario konsep'|'Skenario'|'Situācija'|'Senaryo taslağı'|'Senaryo'|'Scénář'|'Scénario'|'Schema dello scenario'|'Scenārijs pēc parauga'|'Scenārijs'|'Scenár'|'Scenariusz'|'Scenariul de şablon'|'Scenariul de sablon'|'Scenariu'|'Scenario Outline'|'Scenario Amlinellol'|'Scenario'|'Scenarijus'|'Scenarijaus šablonas'|'Scenarij'|'Scenarie'|'Rerefons'|'Raamstsenaarium'|'Primer'|'Pozadí'|'Pozadina'|'Pozadie'|'Plan du scénario'|'Plan du Scénario'|'Osnova scénáře'|'Osnova'|'Náčrt Scénáře'|'Náčrt Scenáru'|'Mate'|'MISHUN SRSLY'|'MISHUN'|'Kịch bản'|'Kontext'|'Konteksts'|'Kontekstas'|'Kontekst'|'Koncept'|'Khung tình huống'|'Khung kịch bản'|'Háttér'|'Grundlage'|'Geçmiş'|'Forgatókönyv vázlat'|'Forgatókönyv'|'Esquema do Cenário'|'Esquema do Cenario'|'Esquema del escenario'|'Esquema de l\'escenari'|'Escenario'|'Escenari'|'Dasar'|'Contexto'|'Contexte'|'Contesto'|'Condiţii'|'Conditii'|'Cenário'|'Cenario'|'Cefndir'|'Bối cảnh'|'Blokes'|'Bakgrunn'|'Bakgrund'|'Baggrund'|'Background'|'B4'|'Antecedents'|'Antecedentes'|'All y\'all'|'Achtergrond'|'Abstrakt Scenario'|'Abstract Scenario')
# STEPS
TOKEN:step_keyword:('하지만'|'조건'|'먼저'|'만일'|'만약'|'단'|'그리고'|'그러면'|'那麼'|'那么'|'而且'|'當'|'当'|'前提'|'假設'|'假如'|'但是'|'但し'|'並且'|'もし'|'ならば'|'ただし'|'しかし'|'かつ'|'و'|'متى'|'لكن'|'عندما'|'ثم'|'بفرض'|'اذاً'|'כאשר'|'וגם'|'בהינתן'|'אזי'|'אז'|'אבל'|'Унда'|'То'|'Онда'|'Но'|'Лекин'|'Когато'|'Када'|'Кад'|'К тому же'|'И'|'Задато'|'Задати'|'Задате'|'Если'|'Допустим'|'Дадено'|'Ва'|'Бирок'|'Аммо'|'Али'|'Агар'|'А'|'Și'|'És'|'anrhegedig a'|'Zatati'|'Zakładając'|'Zadato'|'Zadate'|'Zadano'|'Zadani'|'Zadan'|'Yna'|'Ya know how'|'Ya gotta'|'Y'|'Wtedy'|'When y\'all'|'When'|'Wenn'|'WEN'|'Và'|'Ve'|'Und'|'Un'|'Thì'|'Then y\'all'|'Then'|'Tapi'|'Tak'|'Tada'|'Tad'|'Så'|'Stel'|'Soit'|'Siis'|'Si'|'Quando'|'Quand'|'Quan'|'Pryd'|'Pokud'|'Pokiaľ'|'Però'|'Pero'|'Pak'|'Oraz'|'Onda'|'Ond'|'Oletetaan'|'Og'|'Och'|'O zaman'|'Når'|'När'|'Niin'|'Nhưng'|'N'|'Mutta'|'Men'|'Mas'|'Maka'|'Majd'|'Mais'|'Maar'|'Ma'|'Lorsque'|'Lorsqu\''|'Kun'|'Kuid'|'Kui'|'Khi'|'Keď'|'Ketika'|'Když'|'Kai'|'Kada'|'Kad'|'Jeżeli'|'Ja'|'Ir'|'I CAN HAZ'|'I'|'Ha'|'Givet'|'Given y\'all'|'Given'|'Gitt'|'Gegeven'|'Gegeben sei'|'Fakat'|'Eğer ki'|'Etant donné'|'Et'|'Então'|'Entonces'|'Entao'|'En'|'Eeldades'|'E'|'Duota'|'Donat'|'Donada'|'Diyelim ki'|'Dengan'|'De'|'Dato'|'Dar'|'Dann'|'Dan'|'Dado'|'Dacă'|'Daca'|'DEN'|'Când'|'Cuando'|'Cho'|'Cept'|'Cand'|'Cal'|'But y\'all'|'But'|'Biết'|'Bet'|'BUT'|'Atès'|'Atunci'|'Atesa'|'Angenommen'|'And y\'all'|'And'|'Ama'|'Als'|'Alors'|'Allora'|'Ali'|'Aleshores'|'Ale'|'Akkor'|'Aber'|'AN'|'A také'|'A'|'*'):
# EXAMPLES
TOKEN:examples_keywords:('예'|'例子'|'例'|'サンプル'|'امثلة'|'דוגמאות'|'Сценарији'|'Примери'|'Мисоллар'|'Значения'|'Örnekler'|'Voorbeelden'|'Variantai'|'Tapaukset'|'Scenarios'|'Scenariji'|'Scenarijai'|'Příklady'|'Példák'|'Príklady'|'Przykłady'|'Primjeri'|'Primeri'|'Piemēri'|'Pavyzdžiai'|'Paraugs'|'Juhtumid'|'Exemplos'|'Exemples'|'Exemplele'|'Exempel'|'Examples'|'Esempi'|'Enghreifftiau'|'Eksempler'|'Ejemplos'|'EXAMPLZ'|'Dữ liệu'|'Contoh'|'Cobber'|'Beispiele')

but when I create the module and restart NetBeans it does not recognize all tokens. The Reason is simple: (you used the pyton function ur() but in the .nbs-file this is not applicable) hence german example: "Funktinalität" every char you do not find on an English keyboard, can not be defined in that way like I did in the code above. I used a workarround before (as my plugin does support german) to define "Funktionalität" as ("Funktionalit"."t"). this maybe applicable when there is only one or two such chars, but what should I do with Chinese, Arabian, ...

Hope you'll have the big helping Idea.

aslakhellesoy commented 14 years ago

If I understand this correctly, Netbeans doesn't support UTF-8 in tokens?

QuBiT commented 14 years ago

It looks like that, yes.

aslakhellesoy commented 14 years ago

I would be very surprised if it doesn't support UTF-8. Netbeans is running on the JVM and is probably using the java.util.regex package, which indeed supports UTF-8.

It's more likely something wrong with the way you have generated regexps. They look invalid. You have a single quote on each side of the vertical bar. Why is that? If you look at any of the "Generated ..." links on the wiki page, you'll see that the ones that I have generated with Rake, ERb and Gherkin::I18n.keyword_regexp don't quote each keyword. Example:

http://github.com/aslakhellesoy/cucumber-tmbundle/blob/master/Syntaxes/Cucumber%20Plain%20Text%20Feature.tmLanguage#L146

Did you write the i18n code above by hand, or did you have it generated using the approach I use with Rake, Erb and Gherkin::I18n.keyword_regexp?

Your stuff should probably look more like:

TOKEN:feature_keywords:('기능|機能|功能|フィーチャ|خاصية|תכונה|Функционалност|Функционал|Особина|Могућност|Özellik|Właściwość|Tính năng|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd')

-And this is easy to generate.

QuBiT commented 14 years ago

PROBABLY NOT please look at: http://wiki.netbeans.org/GLFTutorial

older article (old version, but still the same syntax and semantics) http://netbeans.org/community/magazine/html/03/schliemann/

if you have read (just read the part where the tokens are defined) that pages, you'll see why this is not so easy.

BUT: in the new Version (will be ready soon) I will support: CS,DA,DE,EN,ES,ET,FI,FR,HR,HU,ID,IT,LT,LV,NL,NO,PT,PL,RO,SE,SV,SK,TR,VI

that's all I can do.

aslakhellesoy commented 14 years ago

Maybe I can help. Could you put up a Wiki page with build instructions? I'm very familiar with Java, Ant etc, but not at all with Netbeans. Tried this:

$ ant -Dnbplatform.default.harness.dir=/Applications/NetBeans/NetBeans\ 6.8.app/Contents/Resources/NetBeans/harness nbm
Buildfile: build.xml

taskdefs:

-convert-old-project:

common-init:

BUILD FAILED
/Applications/NetBeans/NetBeans 6.8.app/Contents/Resources/NetBeans/harness/build.xml:122: Unknown platform name 'default'.
aslakhellesoy commented 14 years ago

Thanks for that.

I have fixed the UTF-8 issues - all that was needed was to Unicode escape keywords. I have added a code generator and simplified the grammar a little in my fork. All the changes are here: http://github.com/aslakhellesoy/cucumber-netbeans-plugin/commit/356de211c3f6ade370e4659c0e6048f49c3524ee

To regenerate the grammar in the future, just run rake i18n_generate

I hope you'll consider merging this in.

aslakhellesoy commented 14 years ago

Forgot to mention - you'll have to gem install gherkin in order to run the code generator.

QuBiT commented 14 years ago

It is done, new Version 1.6.0 available.

please update: http://wiki.github.com/aslakhellesoy/gherkin/tool-support

aslakhellesoy commented 14 years ago

Excellent! Wiki updated. I'm closing this issue.