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

Import of images using the path from localization files #218

Closed
Svyatoslav16 opened this issue Nov 5, 2020 · 0 comments
Closed

Import of images using the path from localization files #218

Svyatoslav16 opened this issue Nov 5, 2020 · 0 comments

Comments

@Svyatoslav16
Copy link

I'm tried require image with locale file in json
RU file with locales

{
    "connect-all-data-sources-image": "connect-all-data-sources-ru.jpg",
}

EN file with locales

{
    "connect-all-data-sources-image": "connect-all-data-sources-en.jpg",
}

/pages/index.jsx

import React from 'react';
import Img from 'react-optimized-image';
import useTranslation from 'next-translate/useTranslation';
const Index = () => {
     const { t } = useTranslation();
     return (
         <div>
             <Img src={require(`../public/images/${t('common:connect-all-data-sources-image')}`)} />
         </div>
     )
}

but i get some errors:

(node:21318) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:21318) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unhandledRejection listeners added to [process]. Use emitter.setMaxListeners() to increase limit

Is it possible to use this package to optimize images with the localization package? If yes, tell me another way, what I am doing wrong, but if not, I would like to understand the reason, because this is what communities of programmers are for.

Thank you in advance for answering

@Svyatoslav16 Svyatoslav16 changed the title Импорт картинок с использованием пути из файлов локализации Import of images using the path from localization files Nov 6, 2020
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

1 participant