හොඳ ක්රියා පටිපාටී
URL සබැඳි චලකවලට තබන්න
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 client origins array භාවිතයෙන් ඔබට මූලාශ්ර කළමනාකරණය ස්වයංක්රීය කළ හැක.
අපගේ කොම්පොනන්ට් සහ පිටු විවිධ ගොනු වලට වෙන් කර ඇති මෙම උදාහරණය සලකා බලන්න.
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 පිළිබඳ වැඩි විස්තර සඳහා අපගේ server-side rendering උදාහරණ බලන්න.