Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Reusable step definitions and i18n
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
aslak hellesoy  
View profile  
 More options Jul 21, 7:15 pm
From: aslak hellesoy <aslak.helle...@gmail.com>
Date: Wed, 22 Jul 2009 01:15:26 +0200
Local: Tues, Jul 21 2009 7:15 pm
Subject: Reusable step definitions and i18n

Every now and then people ask about how to package reusable step definitions
in a gem.
Another popular request is translations of webrat_steps.rb into other
languages.

Since I want to keep Cucumber slim and easy for me to maintain, I don't want
to package lots of step definitions into Cucumber,
but I do think that reusable step definitions in gems, possibly i18n'ed
could be helpful for a couple of reasons:

1) It would help newbies who are not sure how to write good step definitions
2) It would consolidate our community a little more

For example, on thing that I would like to see in a gem is cucumber's own
step definitions, which are handy
for apps with a command line interface. (They'd have to be honed a little to
be generally useful, but that shouldn't
be a big job).

Here are already a few efforts in this space that I know of:

* http://github.com/nando/mundo-pepino
* http://github.com/dancroak/blitz
* http://github.com/demetriusnunes/swinger
* http://github.com/richdownie/watircuke
* http://github.com/napcs/cucumber_watir
* http://github.com/mdoel/cukesteps
* http://github.com/danielwanja/cucumberwithflex
* http://github.com/fmiopensource/couchdb-cucumber

These are all great little projects, so chip in if you want to help out! Who
wants to create a cucumber_webrat_i18n project? I'd provide Norwegian and
French translations :-)

Aslak


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
aguids  
View profile  
 More options Jul 22, 12:50 am
From: aguids <felipe.do...@gmail.com>
Date: Tue, 21 Jul 2009 21:50:28 -0700 (PDT)
Local: Wed, Jul 22 2009 12:50 am
Subject: Re: Reusable step definitions and i18n
On Jul 21, 8:15 pm, aslak hellesoy <aslak.helle...@gmail.com> wrote:

Last week I started my first rails application using cucumber step
definitions not written in English.

These are the features I wished the cucumber generator had while
setting it up:
1) Localized version of the webrat_steps
2) cucumber.yml with default and autospec profiles set for the chosen
language

My first attempt on translating the steps with maintainability in mind
was to simply call the English steps from the localized ones, as can
be seen on this gist:
http://gist.github.com/151803

Although I have doubled the steps to accomplish the same stuff, I'll
only have to update the translated steps if future releases change the
English regular expressions.

Felipe


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeroen van Dijk  
View profile  
 More options Jul 22, 6:36 am
From: Jeroen van Dijk <jeroentjevand...@gmail.com>
Date: Wed, 22 Jul 2009 12:36:37 +0200
Local: Wed, Jul 22 2009 6:36 am
Subject: Re: [Cucumber:804] Re: Reusable step definitions and i18n

Hi Aslak,

I'm willing to help out. I have been working on a gem that does/will do
precisely what you want. I just put the code I already have on github (
http://github.com/jeroenvandijk/interlingua/<http://www.github.com/jeroenvandijk/interlingua>)
to give you an idea. This could be become part of cucumber or something like
what ActiveSupport is for Rails. Below is an explaination of the features.
Note that it is still far from complete but since you started this thread I
wanted to show what I have already done.

I'm currently working on a application written for Dutch users. I have
decided to write all the features in Dutch because this obviously is closer
to the mindset of the users. However, I also knew that I couldn't use all
the available webrat steps, not to mention all the available plugins (e.g.
pickle, email_spec). Plus Dutch has also some exceptions that make you
define the same steps twice:

English:
Then I should see "a"
And I should see "b"

Dutch:
Dan moet ik "a" zien
En ik moet "b"

As you can see in English you just need one step definition to have two
grammatically correct sentences whereas in Dutch you need two. Because of
all these productivity killers I decided to write my own plugin that would
make this possible without all the hassle.

On http://github.com/jeroenvandijk/interlingua/<http://www.github.com/jeroenvandijk/interlingua>you
can find an alpha version of the plugin I'm working on. The idea is
that
there is one API and for each new language there is a yaml file needed which
define the step translations (see lib/interlingua/languages/nl.yml to get
the idea). The actual regular expressions for the steps are obtained by
parsing the string in the yaml files.

The current features of the plugin (which could also make it interesting for
English features):
- definition of common steps
- exploit of Rails I18n by guessing paths and reporting when translations or
routes are missing:
- easily translate steps and have multiple translations for the same steps
(as above)

TODO:
- Create a test task that tests if an added language is correctly
implemented
- Adding more steps with plugins as pickle as an example

Possible future features:
- exploiting the API by using it for other purposes than testing e.g. for
auto-completion, for creating a visual user manual, translating features in
other languages

I'm very eager for feedback so please let me know if you have ideas for
features or suggestions for improving the architecture etc.

Cheers Jeroen


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kristian  
View profile  
 More options Jul 28, 5:52 am
From: Kristian <kmand...@gmail.com>
Date: Tue, 28 Jul 2009 02:52:27 -0700 (PDT)
Local: Tues, Jul 28 2009 5:52 am
Subject: Re: Reusable step definitions and i18n
I found it curious, that cucumber doesn't seem to have translations in
the languages.yml file for the top level constructs of a feature, such
as "In order" and "As a".
I also had a need for a danish webrat translation. I have since
created a webrat_da.rb. Where would I submit such a patch for reuse?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
aslak hellesoy  
View profile  
 More options Jul 28, 6:12 am
From: aslak hellesoy <aslak.helle...@gmail.com>
Date: Tue, 28 Jul 2009 12:12:45 +0200
Local: Tues, Jul 28 2009 6:12 am
Subject: Re: [Cucumber:858] Re: Reusable step definitions and i18n

> I found it curious, that cucumber doesn't seem to have translations in
> the languages.yml file for the top level constructs of a feature, such
> as "In order" and "As a".

These words aren't parsed by Cucumber. These words don't even exist for
English in the Cucumber codebase. However, the Cucumber.tmbundle uses them
in the feature snippet.

Cucumber ignores everything up to the first Scenario, Scenario Outline or
Background. In fact, even the Feature keyword is ignored. It is currently
only used by syntax highlighting tools such as Cucumber.tmbundle. (Cucumber
might parse the Feature word in the future though).

> I also had a need for a danish webrat translation. I have since
> created a webrat_da.rb. Where would I submit such a patch for reuse?

I won't put webrat_steps translations into Cucumber. Too much maintenance.
It would be great if someone would take Cucumber's Rails generator, extract
it into a separate project on github and package it as a gem
(cucumber-rails). If that happens I think it's OK to have several
translations there.

Aslak


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
aslak hellesoy  
View profile  
 More options Nov 8, 9:09 pm
From: aslak hellesoy <aslak.helle...@gmail.com>
Date: Mon, 9 Nov 2009 03:09:49 +0100
Local: Sun, Nov 8 2009 9:09 pm
Subject: Re: Reusable step definitions and i18n

> Hey Aslak,

>> Could you do this change to cucumber-rails-test, Dennis?

> I did this and guess it works fine, can you verify that? I just sent you a
> pull request.

Looks good. I also moved lib/cucumber/rails from cucumber to my fork
of cucumber-rails. I have deleted all the rails related stuff from
cucumber now. It's currently on my remove-rails branch. Once I get
gemcutter karma from you I'll push cucumber-rails-0.1.1.rc1 and
cucumber 0.4.4.rc1 so people can check if stuff is still working after
this split. If that's ok I'll merge remove-rails onto master and
release cucumber-rails-0.1.1 and cucumber-0.4.4.

Since the "main" cucumber-rails project is yours it is the only one
that can have Github tickets. I have created 2 tickets there and
closed the associated ones in LH. Let's keep the bugs with the
projects. (Already done like this for Cuke4Duke and Cuke4Nuke).

If you don't mind I'd like to control releases of cucumber-rails in
the start - just to see that everything is OK. (git tagging, pushing
gems to gemcutter). Then I'll happily give that honor over to you
Dennis (or anyone else who wants it).

>>> Is there a way to use the localized keywords (instead of Given/When/
>>> Then) in the step definitions?

>> Yes - the methods are aliased when Cucumber parses a Feature file of a
>> different i18n language (which happens before ruby files are loaded).

> Hmm, maybe you can go ahead with the norwegian version and I'll see what I'm
> doing wrong.

http://github.com/aslakhellesoy/cucumber-rails-test/commit/1a8f67c427...
I'm guessing you're not adding the language header properly.

I'll add the Webrat translations later.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google