Git Product home page Git Product logo

Comments (8)

Cs4K1Sr4C avatar Cs4K1Sr4C commented on August 11, 2024 1

I'm not sure about it, but maybe a solution is to remove the import type nextI18NextConfig from '../../next-i18next.config.js'; from the translate.ts.

import { i18n } from 'next-i18next';
import type nextI18NextConfig from '../../next-i18next.config.js';

type Namespace = 'common' | 'agent' | 'constants' | 'message';

export const translate = (
  key: string,
  text?: string | undefined | null,
  ns?: Namespace | null
) => {
  const opts = !!ns ? { ns } : undefined;
  const defaultText = text ? text : key;
  return i18n?.t(key, defaultText, opts) ?? key;
};

change to:

import { i18n } from 'next-i18next';

type Namespace = 'common' | 'agent' | 'constants' | 'message';

export const translate = (
  key: string,
  text?: string | undefined | null,
  ns?: Namespace | null
) => {
  const opts = !!ns ? { ns } : undefined;
  const defaultText = text ? text : key;
  return i18n?.t(key, defaultText, opts) ?? key;
};

from babyagi-ui.

Cs4K1Sr4C avatar Cs4K1Sr4C commented on August 11, 2024 1

One possible solution can be to change the nextI18NextConfig.ns as Array<string> to nextI18NextConfig.ns as string[]. I hope it will solve the problem, let me know if you are still facing with error or warning after changes.

from babyagi-ui.

miurla avatar miurla commented on August 11, 2024 1

Found the cause!
There was a place where translate("key", "defaultValue", 'namespace') was being used as translate("key", 'namespace'). Therefore, namespace would fall back to the default namespace common and the specified key would not be found. I'll fix it.

ex: https://github.com/miurla/babyagi-ui/pull/38/files#diff-6606af50826572564c9bd0c83ae35fee394fef80f5ba7ff1b36ac122fca8f00bR119

from babyagi-ui.

Cs4K1Sr4C avatar Cs4K1Sr4C commented on August 11, 2024 1

@miurla

Thanks for the feedback!

The Translator module I wrote has some bugs and not so dynamic to handle automatically the missing key/value pairs etc..., but I'm working on it to makes the translations interactive mode.
Currently this is the working mechanism of the Translator module:
When there is a new static text to translate you can just easily use the translate("{key}", "{default text in English}", "{namespace}") syntax.
If you run the translator script (npm run translate) it will find and process the mentioned formula in every .ts and .tsx file;
It will extract "key/text/namespace" combinations into an array then translates the text to the selected target language.
So you can use en as source and en as target and it will create the complete English translation and its JSON files; After overwrite the old files - and move the new ones if they are - in the public/locales/en/ directory just easily run again the translator script with an other target language to create the desired complete translation.
When the extraction is done it will change the source code of the file - where from the translatable part has been extracted - to the single translate("{key}", "{namespace}") syntax.

I'm happy about that you could fix the error! πŸ₯³

Unfortunately I'm not a Twitter user (yet, already, yet... I don't know), but I appreciate your mention willingness with a link or just simply using my nick. πŸ™

I'm following this project, so if I have something, you will be notified, and soms I'll take a look on translations and other upgrades too... 😸 🦾 πŸ€– πŸ‘

from babyagi-ui.

miurla avatar miurla commented on August 11, 2024 1

@Cs4K1Sr4C

OK! I'll introduce you using the link πŸ“’
And the translator is great. Thank you for improving it. I'll check the PR 🫑

Indeed, it's like a Translator Agent! Isn't it amazing to have an agent on the code side of the autonomous agent (BabyAGI) product? Apart from this PR, if you don't mind, I'd like to have a casual chat about expanding the Translator Agent. What tool should we use? Should we create a Discord for BabyAGI-UI?

from babyagi-ui.

Cs4K1Sr4C avatar Cs4K1Sr4C commented on August 11, 2024 1

@miurla

Thank you very much, great cooperation! πŸ™ Mine is the honor to be a member of this project too especially of this development process and in the future, I will be happy to lend a helping hand in the development of the project as my time ⏰, competence πŸ’ͺ, and energy ⚑ allow.

I'm 100% active πŸ”₯ and most of the time 0/24 available on Discord. It would be great if you can also move there with the project. There are a lot of users πŸ‘₯ and a perfect platform for the marketing πŸ“£ and for growing the community 🌐 who are interested in the BabyAGI and BabyAGI-UI.

By all means, let's continue a conversation about the module, because BabyAGI is not the first project it has been integrated into... more precisely, it is the first in its form. I have already created a repository πŸ—„οΈ and I would like to create it as a node module which can be installed by npm install πŸ“¦

from babyagi-ui.

miurla avatar miurla commented on August 11, 2024

I deployed and tried it and the error was gone, but I got the same symptoms.
I ran it locally to try and reproduce it, so it may be due to a change in the last commit.

436af45

from babyagi-ui.

miurla avatar miurla commented on August 11, 2024

@Cs4K1Sr4C

I deployed your code πŸŽ‰
Thank you again for your contribution. Your prompt response was very helpful.

I'd like to mention you in the update announcement, do you have a Twitter account? If so, please let me know.

from babyagi-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.