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

Multi-Language Support #165

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

FantomWolf182
Copy link

@FantomWolf182 FantomWolf182 commented Aug 25, 2024

Basically the bot can now chat in any language that is on Google Translate.

The "preferred_language" property accepts a language code or name. Since it's using Google Translate names need to be formatted like on Google Translate. For example if you would like to use Chinese, "preferred_language" would have to be set to "Chinese (Simplified)" or "Chinese (Traditional)" (not case sensitive). Anything the user chat's to the bot is automatically translated to English as I didn't want the AI to bug out. The AI response is then translated to the preferred language the user stated. In case the translation fails, it responds in English.

The command !setPreferredLanguage can be used in chat, and it takes one argument which is the language you want to switch to.

Some examples:

Screenshot 2024-08-25 160848
image
image

@FantomWolf182
Copy link
Author

There are still some changes that need to be made.

Mainly if the preferred language is set to English, it shouldn't translate because the ai responds in English anyways.

@FantomWolf182
Copy link
Author

FantomWolf182 commented Aug 26, 2024

UPDATE:

  1. Now if the preferred language is set to English, it will not translate. If it is not set to English then it will attempt to translate.
  2. Behavior narration like "Aaa I'm On Fire" is now supported.

Copy link
Collaborator

@MaxRobinsonTheGreat MaxRobinsonTheGreat left a comment

Choose a reason for hiding this comment

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

got some work for ya!

settings.js Outdated Show resolved Hide resolved
settings.js Outdated Show resolved Hide resolved
src/agent/agent.js Outdated Show resolved Hide resolved
src/agent/modes.js Outdated Show resolved Hide resolved
src/agent/agent.js Outdated Show resolved Hide resolved
src/agent/agent.js Outdated Show resolved Hide resolved
@@ -286,4 +289,38 @@ export const actionsList = [
return 'Set npc goal: ' + agent.npc.data.curr_goal.name;
}
},
{
name: '!setPreferredLanguage',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like writing to the settings file at runtime. This should just change the language for the current session

@FantomWolf182
Copy link
Author

Ok so a quick update:

Most of the changes requested have been done. There is a translator.js file which contains everything needed to translate messages, and it's functions are called from the file where necessary. Currently the only thing that has not returned is the in-game command. This is because I can't find a straightforward way in js to update the variable in translator.js from action in actions.js

@FantomWolf182
Copy link
Author

It's been a while but I might take a shot at this again

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.

2 participants