'use client';
import { type FC, useState } from 'react';
// This component is used to test the `intlayer transform command`
export const HelloWorld: FC = () => {
// The values here should be extracted
const [state, setState] = useState(
'This is a sentence if a state (should be extracted)'
);
const numberToInsertInString = 10;
const [isClicked, setIsClicked] = useState(false);
// The values here should be extracted
const listOfItems = [
"I'm a list of items (should be extracted as returned by the function) (1)",
"I'm a list of items (should be extracted as returned by the function) (2)",
];
const secondListOfItems = [
// The values here should be extracted
{ key: '1', value: "I'm a second list of items" },
{ key: '2', value: "I'm a second list of items" },
{ key: '3', value: "I'm a second list of items" },
];
const handleClick = () => {
setState(
'This is a sentence if a state changed. Because state is returned as reactNode, this sentence should be extracted'
);
};
return (
Hello World (should be extracted)
I'm a test (should be extracted)
This is a test (should be extracted)
{`This is a string with a number ${numberToInsertInString} (should be extracted)`}
This is a string with a number {numberToInsertInString} (should be
extracted)
{listOfItems.map((item) => (
{item}
))}
{secondListOfItems.map((item) => (
{item.value}
))}
This is a string including '"!@#$%^&*()_+-=[]{} special characters:
This is a paragraph on several lines. Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
);
}
const randomFunction = () => {
console.log('This console log should not be extracted');
return "This is a random function return should be extracted because it's returned by the function";
};
// --- NEW RULE TESTING EXAMPLES ---
export const topLevelTiers = [
{
name: 'Starter', // Single capitalized word -> should be extracted
price: '$0', // Not lowercase 1-2 words, but doesn't start with A-Z... wait, shouldExtract rules: starts with [A-Z], it doesn't. And wordCount <= 2. It will not be extracted!
period: 'forever', // 1 lowercase word -> should NOT be extracted
features: [
'5 benchmark runs/day', // will be extracted
'lower case longer sentence string', // >2 words -> should be extracted
'contact@intlayer.org', // email -> should NOT be extracted
'camelCaseProperty', // 1 lowercase word -> should NOT be extracted
],
},
];
export const useMyCustomHook = () => {
const hookState =
'This string belongs to a custom hook and should be extracted using useIntlayer';
return { hookState };
};
export default HelloWorld;