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

Question, It is possible to have a report with i18n #145

Open
Scot3004 opened this issue Jul 31, 2024 · 4 comments
Open

Question, It is possible to have a report with i18n #145

Scot3004 opened this issue Jul 31, 2024 · 4 comments

Comments

@Scot3004
Copy link

I'm thinking if there's any possibility to give the actions that are performed in another language for example spanish.
Should I write classes with their respective beat for the specific lang?
For example if I need an actor

AnActor.named("Cameron")

How I should implement this

Create a narrator that gets the message in english and process through a .po file dinamically?

Create a class based on each of the classes using custom @beat?
for example

UnActor.llamado("cameron")
@Scot3004 Scot3004 changed the title Question, It is possible to have a report with i18n based on beat Question, It is possible to have a report with i18n Jul 31, 2024
@perrygoy
Copy link
Member

perrygoy commented Jul 31, 2024

This is something that i've thought about quite a lot—how to support other languages.

I'd really love to be able to easily have translations available. For the Narrator's log, yes, it really would be as simple as having a different beat for the perform_as function, like:

from screenpy import See, Silently, beat

class Ver(See):
    @beat("{} ve si {question_to_log} es {resolution_to_log}.")
    def perform_as(self, the_actor: Actor) -> None:
        Silently(super(Ver, self)).perform_as(the_actor)  # might work?

Edit: I just realized this probably wouldn't work very well with the Silently, because everything inside of this See would be muted. But without the Silently, the English text would also be read. It's a bit tricky.

That would allow the Narrator to read the Spanish, as long as you made subclasses for all of the Actions you used. The tests themselves would still be using the English methods, though.

Making the methods be Spanish, too, you might be able to do...

class UnActor(Actor):
    llamado = Actor.named
    quién_puede = Actor.who_can
    # ...

That feels a little strange, but i think it should work!

As i said, i'm very interested in this. If you try one of these approaches, can you share how successful it was?

@perrygoy
Copy link
Member

We might need to do some work to more easily allow translations, like Django's _ function or something. I'll be thinking more about this!

@bandophahita
Copy link
Contributor

I'm not well versed in other languages but I have thought about multi language support and one aspect we'll likely need to figure out is how to handle grammar issues depending on the language.

The current structure of the screenplay pattern is actor-centric because that's how English has a tendency to flow.
Subject -> verbs -> noun. "I go to the market."

Whereas some languages might structure the sentence "To the market, I go."
My hunch is some languages will just end up reading like they ran though google translate; which I'm not sure can be helped.

@Scot3004
Copy link
Author

Spanish can be as well actor centric, but for instance in english we have a passive voice like
The windows have been cleaned.
https://learnenglish.britishcouncil.org/grammar/english-grammar-reference/active-passive-voice

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

No branches or pull requests

3 participants