React üzerinde çeviri metne link ekleme (i18next Trans)

Web geliştirme ile ilgili konuları burada bulabilirsiniz
Cevapla
Kullanıcı avatarı
melihcelenk
Site Admin
Mesajlar: 212
Kayıt: 05 Eki 2021, 03:23

React üzerinde çeviri metne link ekleme (i18next Trans)

Mesaj gönderen melihcelenk »

style.css

Kod: Tümünü seç

.link-text {
    color:#0009c6
}
LinkText.js

Kod: Tümünü seç

import React from 'react';

export const LinkText = (props) => {
    return (
        <a className="link-text" href={props.to || '#'} target="_blank" title={props.title || ''}>
            {props.children}
        </a>
    );
};
ContactForm.js

Kod: Tümünü seç

<Trans
    i18nKey={i18n.t("contactus.clarificationagreetext", { lng })}
    components={{
    link1: <LinkText to={link1} title="My link1" />
/>
i18n.js

Kod: Tümünü seç

import i18next from 'i18next';
import { initReactI18next } from "react-i18next";

i18next
  .use(initReactI18next)
  .init({
    interpolation: {
      // React already does escaping
      escapeValue: false,
    },
    fallbackLng: "en",
    lng: 'en', // 'en' | 'es'
    // Using simple hardcoded resources for simple example
    resources: {
      en: {
        translation: {
        ...
         contactus: {
           ...
           clarificationagreetext: 'I accept the limited and measured processing of my personal data collected verbally, in writing or electronically, in connection with the purpose of processing, for reasons arising from the explicit consent specified in the <link1>Clarification Text</link1> by the data controller.'
        ...
         }
        } 
       } 
     tr: {
        translation: {
           contactus: {
        ...
        clarificationagreetext: 'Veri sorumlusu tarafından <link1>Aydınlatma Metni</link1>\'nde belirtilen açık rızanın alınmasından kaynaklanan nedenlerle sözlü, yazılı ya da elektronik ortamda toplanan kişisel verilerimin işleme amacı ile bağlantılı, sınırlı ve ölçülü işlenmesini kabul ediyorum.'
          }
         }
        }
        
Cevapla