You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question, It is possible to have a report with i18n #145
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
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[/+]on 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:
fromscreenpyimportSee, Silently, beatclassVer(See):
@beat("{} ve si {question_to_log} es {resolution_to_log}.")defperform_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...
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.
Thinking a little more about this -- There are a couple of things to consider for language translation; The code and the logging.
My initial though was aliases could be created for each language but that doesn't translate any of the arguments.
classUnActor(Actor):
llamado=Actor.namedquién_puede=Actor.who_canUnActor.llamado(name="Marcel") # little awkward in those cases where named arguments are utilized.
I read about using decorators to make argument aliases, perhaps something similar could be done here?
Secondly, the strings used by pacing (beat, aside, etc), describes, matchers (resolutions) would also need to be translated and swapped out.
classSee:
defdescribe(self) ->str:
"""Describe the Action in present tense."""returnf"See if {self.question_to_log} is {self.resolution_to_log}."# <--- this@beat("{} sees if {question_to_log} is {resolution_to_log}.") # <--- thisdefperform_as(self, the_actor: Actor) ->None:
"""Direct the Actor to make an observation."""ifisinstance(self.question, Answerable):
value: object=self.question.answered_by(the_actor)
else:
# must be a value instead of a question!value=self.questionaside(f"the actual value is: {represent_prop(value)}") # <--- this ** needs a callback?reason=""ifisinstance(self.question, ErrorKeeper):
reason=f"{self.question.caught_exception}"assert_that(value, self.resolution.resolve(), reason)
The 3rd string needs a value passed in, so static strings aren't sufficient. It would need to be a function.
From a maintainability standpoint, I'm thinking we would want to create string var modules (for each language) which are then referenced based on runtime language configuration.
classSee:
defdescribe(self) ->str:
"""Describe the Action in present tense."""returnlang.see.describe@beat(lang.see.perform_beat) # <--- thisdefperform_as(self, the_actor: Actor) ->None:
"""Direct the Actor to make an observation."""ifisinstance(self.question, Answerable):
value: object=self.question.answered_by(the_actor)
else:
# must be a value instead of a question!value=self.questionaside(lang.see.perform_aside_actual(value)) # <--- this
Activity
[-]Question, It is possible to have a report with i18n based on beat[/-][+]Question, It is possible to have a report with i18n[/+]perrygoy commentedon 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
beatfor theperform_asfunction, like:Edit: I just realized this probably wouldn't work very well with the
Silently, because everything inside of thisSeewould be muted. But without theSilently, 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...
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 commentedon Jul 31, 2024
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 commentedon Aug 13, 2024
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 commentedon Aug 13, 2024
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
bandophahita commentedon Apr 15, 2026
Thinking a little more about this -- There are a couple of things to consider for language translation; The code and the logging.
My initial though was aliases could be created for each language but that doesn't translate any of the arguments.
I read about using decorators to make argument aliases, perhaps something similar could be done here?
Secondly, the strings used by
pacing(beat, aside, etc), describes, matchers (resolutions) would also need to be translated and swapped out.The 3rd string needs a value passed in, so static strings aren't sufficient. It would need to be a function.
From a maintainability standpoint, I'm thinking we would want to create string var modules (for each language) which are then referenced based on runtime language configuration.