ਸਭ ਤੋਂ ਵਧੀਆ ਅਭਿਆਸ
URLs ਨੂੰ ਵੈਰੀਏਬਲ ਵਿੱਚ ਰੱਖੋ
ਜਦੋਂ URLs ਜਾਂ ਇਸੇਤਰਾਂ ਡਾਟਾ ਵਾਲੀਆਂ ਸਟਰਿੰਗਜ਼ ਦਾ ਅਨੁਵਾਦ ਕੀਤਾ ਜਾਂਦਾ ਹੈ, ਤਾਂ ਇਹ ਇੱਕ ਚੰਗੀ ਪ੍ਰਥਾ ਮੰਨੀ ਜਾਂਦੀ ਹੈ ਕਿ ਇਹ URLs ਵੈਰੀਏਬਲਾਂ ਵਿੱਚ ਰੱਖੇ ਜਾਣ ਤੇ ਫਿਰ ਆਪਣੀਆਂ ਟੈਂਪਲੇਟਾਂ ਵਿੱਚ ਉਨ੍ਹਾਂ ਦਾ ਹਵਾਲਾ ਦਿੱਤਾ ਜਾਵੇ।
<Translate
string={`Click <a href="{{url}}">here</a>`}
variables={{url: 'https://tacotranslate.com'}}
/>
ARIA ਲੇਬਲ ਵਰਤੋ
ਜਦੋਂ ਇੰਟਰੈਕਟਿਵ ਤੱਤਾਂ ਜਿਵੇਂ ਕਿ ਬਟਨਾਂ ਦਾ ਟੈਕਸਟ ਅਨੁਵਾਦ ਕੀਤਾ ਜਾ ਰਿਹਾ ਹੋਵੇ, ਤਾਂ ਪਹੁੰਚਯੋਗਤਾ ਨੂੰ ਯਕੀਨੀ ਬਣਾਉਣ ਲਈ ARIA ਲੇਬਲ ਸ਼ਾਮਲ ਕਰਨਾ ਮਹੱਤਵਪੂਰਨ ਹੁੰਦਾ ਹੈ। ARIA ਲੇਬਲ ਸਕ੍ਰੀਨ ਰੀਡਰਾਂ ਨੂੰ ਤੱਤ ਦੇ ਫੰਕਸ਼ਨ ਬਾਰੇ ਵਰਣਨਾਤਮਕ ਜਾਣਕਾਰੀ ਪ੍ਰਦਾਨ ਕਰਨ ਵਿੱਚ ਮਦਦ ਕਰਦੇ ਹਨ।
ਉਦਾਹਰਨ ਵੱਜੋਂ, ਜੇ ਤੁਹਾਡੇ ਕੋਲ ਇੱਕ ਬਟਨ ਹੈ ਜੋ ਉਪਭੋਗਤਾਵਾਂ ਨੂੰ ਕੋਡ ਬਲਾਕ ਵਿੱਚੋਂ ਟੈਕਸਟ ਕਾਪੀ ਕਰਨ ਦਿੰਦਾ ਹੈ, ਤਾਂ ਤੁਸੀਂ aria-label
ਗੁਣ ਦਾ ਇਸਤੇਮਾਲ ਕਰਕੇ ਸਪਸ਼ਟ ਵਰਣਨ ਮੁਹੱਈਆ ਕਰਵਾ ਸਕਦੇ ਹੋ:
<Translate
aria-label={useTranslation('Copy to clipboard')}
string="Copy"
/>
ਇਸ ਬਾਰੇ ਕੁਝ ਗੱਲ ਬਹੁਤ ਮੈਟਾ ਲੱਗਦੀ ਹੈ।
ਗਲੋਬਲ ਉਤਪੱਤ ਸਰਣੀ ਅਤੇ ਬਹੁਤ ਸਾਰੇ ਕੰਪੋਨੇਟ ਉਤਪੱਤ
ਇਹ ਪੈਟਰਨ ਸਿਰਫ਼ Next.js Pages Router ਦੀ ਵਰਤੋਂ ਕਰਨ ਵੇਲੇ ਹੀ ਕੰਮ ਕਰਦਾ ਹੈ।
ਜਦੋਂ ਵੱਡੀਆਂ ਐਪਲੀਕੇਸ਼ਨਾਂ ਨਾਲ ਕੰਮ ਕਰਦੇ ਹੋ, ਤਾਂ ਸਟ੍ਰਿੰਗਜ਼ ਅਤੇ ਅਨੁਵਾਦਾਂ ਨੂੰ ਕਈ ਛੋਟੇ, ਵੱਖ-ਵੱਖ ਮੂਲਾਂ ਵਿੱਚ ਵੰਡਣਾ ਲਾਭਦਾਇਕ ਹੁੰਦਾ ਹੈ। ਇਹ ਤਰੀਕਾ ਬੰਡਲ ਆਕਾਰ ਅਤੇ ਟ੍ਰਾਂਸਫਰ ਸਮਿਆਂ ਨੂੰ ਘਟਾਉਣ ਵਿੱਚ ਮਦਦ ਕਰਦਾ ਹੈ, ਜਿਸ ਨਾਲ ਪ੍ਰਭਾਵਸ਼ালী ਅਤੇ ਸਕੇਲਯੋਗ ਲੋਕਲਾਈਜੇਸ਼ਨ ਸੁਨਿਸ਼ਚਿਤ ਹੁੰਦੀ ਹੈ।
ਜਦੋਂ ਇਹ ਸਿਰਫ਼ ਕਲਾਈਐਂਟ ਸਾਈਡ 'ਤੇ ਰੈਂਡਰਿੰਗ ਕਰਦਿਆਂ ਸੌਖਾ ਹੁੰਦਾ ਹੈ, ਤਾਂ ਸਰਵਰ-ਸਾਈਡ ਰੈਂਡਰਿੰਗ ਲਈ ਅਨੁਵਾਦ ਲੈਣ ਦੌਰਾਨ ਮੂਲਾਂ ਦਾ ਪ੍ਰਬੰਧਨ ਕਰਨਾ ਤੇਜ਼ੀ ਨਾਲ ਜਟਿਲ ਹੋ ਜਾਂਦਾ ਹੈ। ਹਾਲਾਂਕਿ, ਤੁਸੀਂ TacoTranslate ਕਲਾਈਐਂਟ origins
ਐਰੇ ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਮੂਲ ਪ੍ਰਬੰਧਨ ਨੂੰ ਸੁਚਾਲਿਤ ਕਰ ਸਕਦੇ ਹੋ।
ਇਸ ਉਦਾਹਰਣ ਨੂੰ ਵੇਖੋ, ਜਿੱਥੇ ਅਸੀਂ ਆਪਣੇ ਕੰਪੋਨੈਂਟ ਅਤੇ ਪੰਨਿਆਂ ਨੂੰ ਵੱਖ-ਵੱਖ ਫਾਈਲਾਂ ਵਿੱਚ ਵੰਡਿਆ ਹੈ।
import TacoTranslate, {Translate} from 'tacotranslate/react';
import tacoTranslate from '../tacotranslate-client';
// Set an origin name for this component
const origin = 'components/pricing-table';
// Push the origin into the origins array as this file is imported
tacoTranslate.origins.push(origin);
export default function PricingTable() {
return (
<TacoTranslate origin={origin}>
<Translate string="Pricing table" />
// ...
</TacoTranslate>
);
}
import TacoTranslate, {Translate} from 'tacotranslate/react';
import getTacoTranslateStaticProps from 'tacotranslate/next/get-static-props';
import tacoTranslateClient from '../tacotranslate-client';
import PricingTable from '../components/pricing-table';
const origin = 'pages/pricing';
tacoTranslateClient.origins.push(origin);
export default function PricingPage() {
return (
<TacoTranslate origin={origin}>
<Translate string="Pricing page" />
<PricingTable />
</TacoTranslate>
);
}
// We will now fetch translations for all imported components and their origins automatically
export async function getStaticProps(context) {
return getTacoTranslateStaticProps(context, {client: tacoTranslateClient});
}
ਸਾਡੇ ਸਰਵਰ-ਸਾਈਡ ਰੇਂਡਰਿੰਗ ਉਦਾਹਰਨਾਂ ਨੂੰ ਵੇਖੋ getTacoTranslateStaticProps
ਬਾਰੇ ਹੋਰ ਜਾਣਕਾਰੀ ਲਈ।