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

HI, there, i got a problem stuck me, can you help me? #126

Open
tianzige886 opened this issue Nov 30, 2023 · 6 comments
Open

HI, there, i got a problem stuck me, can you help me? #126

tianzige886 opened this issue Nov 30, 2023 · 6 comments

Comments

@tianzige886
Copy link

tianzige886 commented Nov 30, 2023

i use this package in React-Native project, and I want to translate the content returned from my Node server directly on frontend, but the content is a JSON data, like [{a: "text", b: "text2", id: 1}]. is there have a good solution to implement it? help~ help~ help~^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^_^. i've tried this way to translate the data. but it didn't work!!!

const formatTypes = async () => {
let list = [];
try {
for (const item of typeList) {
const {text} = await translate(item.key, {
to: 'en',
});
let obj = item;
obj.key = text;
list.push(obj);
}
console.log('list-------------------------');
console.log(list);
} catch (e) {
console.log('error-------------------------');
console.log(e);
}
};

@vitalets
Copy link
Owner

vitalets commented Dec 1, 2023

could you show the output of console.log(typeList)?

@tianzige886
Copy link
Author

[{"id": "", "key": "全部", "value": ""}, {"id": "60996496040d1a25940d9ea1", "color": "#d3c1d7#e8e3e6#c2b8c3", "key": "购物", "value": "5", "wordColor": "#f000ff"}, {"id": "6099641c1c9b4204ca3a552e", "color": "#ddcfba#f9f4ea_#c0b7a9", "key": "美食", "value": "1", "wordColor": "#fe8300"}]

@tianzige886
Copy link
Author

i want to translate the "key" in json

@vitalets
Copy link
Owner

vitalets commented Dec 4, 2023

Your code looks correct. What is the output and error?

@tianzige886
Copy link
Author

error-------------------------
LOG [TypeError: Network request failed]

here it is

@vitalets
Copy link
Owner

@tianzige886 please provide a full reproducible code. Otherwise it's impossible to help.

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

2 participants