This is a Next.js project bootstrapped
with create-next-app.
A Small Tip:
Lisan Loader Plugin is meant for pure javascript projects.
When using a framework in your project like react, next.js or vue.js,
we recommend you to take advantage of
most recent EcmaScript features like dynamic import.
To learn more see Hello World (Next.js)
example, where dynamic import was used.
Purpose of this example to demonstrate a minimal setup to use LisanJS with lisan-plugin-loader which is also compatible with server side rendering..
npm init next-app 04-nextjs-ssr
cd ./04-nextjs-ssr
touch .lisanrcFirst run the application to see if everything works fine:
npm run devIf everything works fine, continue as below.
1.1. Install Lisan:
npm install lisan lisan-plugin-loader
npm install lisan-cli --save-dev1.2. Add scripts to package.json:
1.3. Add dictionaries to .gitignore (Optional)
node_modules/
public/dictionaries/
Update the .lisanrc config as below:
{
"compile": {
"inputDir": "translations",
"outputDir": "public/dictionaries",
"returnArray": true
}
}
returnArrayoption makes dictionaries compatible with JSX. Learn more at JSX Interpolation
mkdir -p translations/en/ && touch translations/en/main.json
mkdir -p translations/tr/ && touch translations/tr/main.jsonMigrate content from ./pages/index.js to ./translations/en/main.json.
{
"locale": "en",
"entries": {
"text.loading": "Loading...",
"document.title": "Create Lisan App",
"page.title": "Welcome to ${linkElement}",
"page.description": " Get started by editing ${codeElement}",
"section.documentation.title": "Documentation",
"section.documentation.desc": "Find out more about technical details and best practices.",
"section.translations.title": "Lisan Literal",
"section.translations.desc": "See full capabilities of Lisan Literal",
"section.examples.title": "Examples",
"section.examples.desc": "Explore many different use cases of Lisan.",
"section.try_compiler.title": "Try Online Compiler",
"section.try_compiler.desc": "You can test capabilities of lisan-compiler online.",
"powered.by": "Powered by ${logoImgElement}"
}
}You can see ./pages/index.js from here.
To run lisan compiler in watch mode you can use -w flag.
npm run lisan:compile -- -wnpm run dev
{ // ... "scripts": { "lisan:compile": "lisan compile" // ..rest of the scripts } }