[rspec-devel] New spoken language support for cucumber

Lian Liming lianliming at gmail.com
Thu Oct 9 12:01:23 EDT 2008


Hi all,

I still haven't found any documentation on how to add a new spoken
language support to cucumber. I have tried following two steps to add
a new one.

1) Add a new section to the languange.yaml and identify the
translations of the keywords.
2) run rake -f gem_tasks/treetop.rake treetop:compile

The new language I am trying to add is my mother tongue -- Chinese. By
applying above steps, it basically works. The only thing I have to
deal with is that, there is no space between keyword and rest of the
sentence in Chinese language. That is also the important difference
between Asian languages(including Chinese, Japanese, Korea)  and
western languages (those have been supported in cucumber).

Take a look at following example:

In English: Given I have entered 50 into the calculator
In Chinese: 假如我已经在计算器中输入了50

To support native Chinese conventions, I have to change the treetop
rules a little bit as following:

----  diff --------
34c34
<     scenario_keyword space? name:line_to_eol steps:(space step_sequence)? {
---
>     scenario_keyword space name:line_to_eol steps:(space step_sequence)? {
99c99
<     given_scenario_keyword space? name:line_to_eol {
---
>     given_scenario_keyword space name:line_to_eol {
108c108
<     step_keyword space? name:line_to_eol {
---
>     step_keyword space name:line_to_eol {
----  end of diff --------

This change targets Asian languages and I don't know whether it breaks
the conventions of western languages. I also would like to know if
there is any more flexible solution of supporting different kinds of
spoken languages. Any ideas?

Liming


More information about the rspec-devel mailing list