Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to translations to codeceptjs #189

Merged
merged 7 commits into from Aug 7, 2016

Conversation

abner
Copy link
Contributor

@abner abner commented Aug 5, 2016

Added feature to allow define translations to the helpers actions and also to the default Iactor.

Added a folder translations where contributors would add translations for their own languagues.

The feature actually works like this: In your concept.json file you add a translation key with some of the name of a supported language or you can also point to a file in your project path.

Example

{
  "tests": "./e2e/features/*.js",
  "timeout": 10000,
  "output": "./e2e/outputs",
  "translation": "pt-BR",
  "helpers": {
    "Protractor": {
      "url": "http://localhost:3000/",
      "host": "127.0.0.1",
      "port": 4444,
      "browser": "phantomjs",
      "rootElement": "body"
    }
  },

  "bootstrap": false,
  "mocha": {},
  "name": "my-project"
}

Using this will allow to write your steps in portuguese:

Feature('Acesso a tela de Login');

Scenario('Testar se a tela de login está acessível', (Eu) => {
    Eu.naoEstouEmAplicacaoAngular();
    Eu.estouNaPagina('http://localhost:3000/')
    Eu.vejo('My App');
});

And the report to codeceptjs run --steps will show

Acesso a tela de Login --
Testar se a tela de login está acessível
• Eu nao estou em aplicacao angular
• Eu estou na pagina "http://localhost:3000/"
• Eu vejo "My App"
✓ OK in 413ms

OK | 1 passed // 462ms

@@ -0,0 +1,56 @@


module.exports = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The explicit call to module.exports is really necessary? I think that the translation file needs be a plain .json file instead a .js file

Copy link
Contributor

@DavertMik DavertMik Aug 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me to have it as .json but I don't see if it is necessary

@mfdeveloper
Copy link

mfdeveloper commented Aug 5, 2016

Awesome @abner !! This is a amazing feature :)

@DavertMik
Copy link
Contributor

Wow! Really cool.

@DavertMik DavertMik merged commit e2f818e into codeceptjs:master Aug 7, 2016
@DavertMik
Copy link
Contributor

Thank you. I will play a bit with that

@DavertMik
Copy link
Contributor

I have done some refactoring there #194
The next thing we should think about is to use localized Scenario/Before/Feature function names.
Also the question is about documentation. Ideally we should translate function references, in reality it will be pretty hard to do, so probably just add method aliases into the Helper references.

@DavertMik
Copy link
Contributor

Ok, I have written small reference on using translations: http://codecept.io/reports/
@abner could you help me a bit and add some Portuguese examples to https://github.com/Codeception/CodeceptJS/blob/master/docs/translation.md ?

Thanks!

@DavertMik
Copy link
Contributor

@sacuribraimo
Copy link

Hi,
Is there a way to localize the messages used in I.see('My App') to a message file where there is translation to 'Minha App'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants