strapi-to-lokalise-plugin
v0.1.72
Published
Preview and sync Lokalise translations from Strapi admin
Maintainers
Readme
Lokalise Sync - Strapi Plugin
Preview and sync Lokalise translations directly from your Strapi admin panel. This plugin is fully compatible with Strapi v4.x and Strapi v5.x.
🔴 CRITICAL: STRAPI V4 INSTALLATION GUIDE
⚠️ MUST READ BEFORE INSTALLING ON STRAPI V4!
This section contains ALL critical steps and common mistakes to ensure the plugin works correctly on Strapi v4.25.15 and all v4.x versions.
✅ Step-by-Step Installation for Strapi v4
1. Verify Node.js Version (REQUIRED)
Strapi v4.25.15 requires Node.js 18.x - 20.x
node --versionMust show: v18.x.x, v19.x.x, or v20.x.x
If wrong version:
- Windows: Install nvm-windows from https://github.com/coreybutler/nvm-windows/releases
nvm install 20.19.5 nvm use 20.19.5 - Mac/Linux: Use nvm
nvm install 20.19.5 nvm use 20.19.5
2. Install the Plugin
npm install strapi-to-lokalise-plugin@latest⚠️ Use
--legacy-peer-depsif you get dependency errors:npm install strapi-to-lokalise-plugin@latest --legacy-peer-deps
3. Configure the Plugin (CRITICAL - MOST COMMON MISTAKE!)
❌ MISTAKE: Thinking the plugin will work without configuration
✅ CORRECT: You MUST create config/plugins.js - it doesn't exist by default!
Create this file: config/plugins.js (in your Strapi project root)
Copy and paste this EXACT code:
module.exports = {
'lokalise-sync': {
enabled: true,
},
};⚠️ CRITICAL NOTES:
- ✅ File must be named
plugins.js(notplugins.ts) - ✅ File must be in
config/folder (NOTsrc/config/) - ✅ Plugin ID is
'lokalise-sync'(with quotes and hyphen) - ❌ DO NOT use
strapi-to-lokalise-plugin(that's the npm package name, not the plugin ID!)
Full path example:
- ✅
C:\your-project\config\plugins.js - ❌
C:\your-project\src\config\plugins.js(WRONG!)
4. Create Environment File (REQUIRED)
❌ MISTAKE: Missing .env file causes authentication errors
✅ CORRECT: Create .env file with required secrets
Create this file: .env (in your Strapi project root)
Minimum required variables:
HOST=0.0.0.0
PORT=1337
# Generate these using: node -e "console.log(require('crypto').randomBytes(16).toString('base64'))"
# Run the command 4 times to get 4 keys
APP_KEYS=yourKey1,yourKey2,yourKey3,yourKey4
# Generate using: node -e "console.log(require('crypto').randomBytes(16).toString('base64'))"
API_TOKEN_SALT=yourApiTokenSalt
# Generate using: node -e "console.log(require('crypto').randomBytes(16).toString('base64'))"
ADMIN_JWT_SECRET=yourAdminJwtSecret
# Generate using: node -e "console.log(require('crypto').randomBytes(16).toString('base64'))"
TRANSFER_TOKEN_SALT=yourTransferTokenSaltQuick generate script (Windows):
Create CREATE_ENV.bat in your project root:
@echo off
echo HOST=0.0.0.0 > .env
echo PORT=1337 >> .env
node -e "console.log('APP_KEYS=' + Array(4).fill(0).map(() => require('crypto').randomBytes(16).toString('base64')).join(','))" >> .env
node -e "console.log('API_TOKEN_SALT=' + require('crypto').randomBytes(16).toString('base64'))" >> .env
node -e "console.log('ADMIN_JWT_SECRET=' + require('crypto').randomBytes(16).toString('base64'))" >> .env
node -e "console.log('TRANSFER_TOKEN_SALT=' + require('crypto').randomBytes(16).toString('base64'))" >> .env
echo .env file created successfully!Then run: CREATE_ENV.bat
5. Configure Server Settings (REQUIRED for Cookies/Auth)
File: config/server.js
Ensure it contains:
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
app: {
keys: env.array('APP_KEYS'), // CRITICAL for cookies!
},
proxy: true,
url: env('PUBLIC_URL', 'http://localhost:1337'),
});6. Configure Admin Settings (REQUIRED for Cookies)
File: config/admin.js
Ensure it contains:
module.exports = ({ env }) => ({
auth: {
secret: env('ADMIN_JWT_SECRET'),
},
cookies: {
secure: false, // MUST be false for localhost
},
});7. Configure Database (REQUIRED)
File: config/database.js
For SQLite (development):
module.exports = ({ env }) => ({
connection: {
client: 'sqlite', // Use 'sqlite' NOT 'sqlite3' or 'better-sqlite3'
connection: {
filename: env('DATABASE_FILENAME', '.tmp/data.db'),
},
useNullAsDefault: true,
},
});⚠️ CRITICAL:
- ✅ Use
client: 'sqlite'(Strapi v4 recognizes this) - ✅ Install
better-sqlite3package:npm install better-sqlite3 --legacy-peer-deps - ❌ DO NOT use
client: 'sqlite3'orclient: 'better-sqlite3'
8. Clear Cache and Restart (REQUIRED After Installation)
⚠️ MISTAKE: Not clearing cache causes old errors
✅ CORRECT: Always clear cache after installing/updating
# Windows
rmdir /s /q .cache build
# Mac/Linux
rm -rf .cache build
# Then restart
npm run developAlso clear browser cache:
- Press
Ctrl+Shift+R(Windows) orCmd+Shift+R(Mac) - Or: DevTools (F12) → Right-click refresh → "Empty Cache and Hard Reload"
9. Common Mistakes to Avoid
| ❌ WRONG | ✅ CORRECT |
|--------------|---------------|
| Plugin ID: strapi-to-lokalise-plugin | Plugin ID: 'lokalise-sync' |
| File: src/config/plugins.js | File: config/plugins.js |
| File: config/plugins.ts (v4) | File: config/plugins.js (v4) |
| Database: client: 'sqlite3' | Database: client: 'sqlite' |
| Missing .env file | Create .env with APP_KEYS, etc. |
| Not clearing cache | Always clear .cache and build folders |
| Wrong Node version | Use Node 18.x - 20.x for v4.25.15 |
10. Verify Installation
After following all steps above, check:
Plugin appears in sidebar:
- Log in to admin panel
- Look for "Lokalise Sync" in left sidebar
- If missing → check
config/plugins.jsexists and has correct content
Routes registered:
- Check terminal logs when Strapi starts
- Should see:
[lokalise-sync] Routes count: 18 - Should see:
POST /lokalise-sync/settings route registered: true
Settings page loads:
- Click on "Lokalise Sync" in sidebar
- Should see settings form
- If 405 error → clear cache and restart
11. If Plugin Doesn't Appear
Check in order:
- ✅
config/plugins.jsexists and contains correct code - ✅ Plugin ID is
'lokalise-sync'(not package name) - ✅ File is in
config/folder (notsrc/config/) - ✅ Restarted Strapi after creating config file
- ✅ Cleared cache (
.cacheandbuildfolders) - ✅ Cleared browser cache (hard refresh)
- ✅ Check terminal for errors when Strapi starts
🟢 STRAPI V5 INSTALLATION (SIMPLER!)
Strapi v5 installation is simpler:
Install:
npm install strapi-to-lokalise-plugin@latestConfigure: Edit existing
config/plugins.ts:export default { 'lokalise-sync': { enabled: true, }, };Restart:
npm run develop
That's it! Strapi v5 handles most configuration automatically.
🔴 CRITICAL ISSUES & SOLUTIONS
Issue 1: "405 Method Not Allowed" When Saving Settings
This is FIXED in version 0.1.71+
If you still see 405 errors:
Update to latest version:
npm install strapi-to-lokalise-plugin@latestClear all cache:
rmdir /s /q .cache build # Windows rm -rf .cache build # Mac/LinuxRestart Strapi:
npm run developClear browser cache:
- Press
Ctrl+Shift+RorCmd+Shift+R
- Press
Issue 2: Plugin Not Appearing in Sidebar
Most common cause: Missing or incorrect config/plugins.js
Solution:
- ✅ Ensure
config/plugins.jsexists (create it if missing!) - ✅ Contains exactly:
module.exports = { 'lokalise-sync': { enabled: true, }, }; - ✅ Restart Strapi after creating file
- ✅ Clear cache
Issue 3: "401 Unauthorized" Errors
Causes:
- Missing
APP_KEYSin.envfile - Missing cookie configuration
- External auth conflict (Clerk/Auth0)
Solutions:
Ensure
.envhas APP_KEYS:APP_KEYS=key1,key2,key3,key4 ADMIN_JWT_SECRET=yourSecretEnsure
config/server.jshas:app: { keys: env.array('APP_KEYS'), },Ensure
config/admin.jshas:cookies: { secure: false, },
Issue 4: Slow Content Type Creation/Save (50+ seconds)
⚠️ THIS IS NORMAL BEHAVIOR - NOT A PLUGIN ISSUE!
When you create or save a content type in Strapi v4, Strapi automatically:
- Restarts the server
- Rebuilds all routes
- Regenerates TypeScript types
This can take 30-60 seconds - this is expected behavior, not an error!
Why it happens:
- Strapi needs to rebuild the entire route structure
- TypeScript types need to be regenerated
- The admin panel needs to reload with new content types
This is NOT caused by the plugin - it's how Strapi v4 works.
To speed up (slightly):
- Use
--watch-adminflag:npm run develop -- --watch-admin - Avoid creating multiple content types in quick succession
- Be patient - the restart is required for Strapi to work correctly
What to do:
- ✅ Wait for the restart to complete (30-60 seconds is normal)
- ✅ Don't interrupt the process
- ✅ The "restart taking longer than expected" message is normal - just wait
✨ Features
- 🔄 Bi-directional Sync: Sync translations between Strapi and Lokalise
- 👀 Preview Mode: Preview translations before syncing
- 🎯 Selective Sync: Choose which content types and locales to sync
- ⚡ Fast & Efficient: Optimized sync process with progress tracking
- 🔐 Secure: API credentials stored securely in plugin settings
- 🎨 Zero Dependencies: No conflicts with Strapi design system packages
📋 Requirements
Strapi Version Compatibility
- Strapi v4.1.0+ through v4.x (all versions)
- Strapi v5.0.0+ (all versions)
Node.js Version Requirements
⚠️ IMPORTANT: Node.js version depends on your Strapi version!
- For Strapi v4.x: Node.js 14.19.1 through 18.x.x (recommended: 18.x or 20.x)
- For Strapi v5.x: Node.js 18.0.0 through 22.x.x (recommended: 18.x or 20.x)
Check your Node.js version:
node --versionIf you have the wrong Node.js version:
Use nvm (Node Version Manager) - Recommended:
Windows:
- Install from: https://github.com/coreybutler/nvm-windows/releases
- Then run:
nvm install 20.19.5 nvm use 20.19.5
Mac/Linux:
- Install from: https://github.com/nvm-sh/nvm
- Then run:
nvm install 20.19.5 nvm use 20.19.5
Or download Node.js directly:
- Download from: https://nodejs.org/
- Choose LTS version 18.x or 20.x for maximum compatibility
Other Requirements
- Lokalise Account: Valid API token with appropriate permissions
📦 Quick Installation
For Strapi v4
# 1. Install
npm install strapi-to-lokalise-plugin@latest --legacy-peer-deps
# 2. Create config/plugins.js
# Copy code from Step 3 in CRITICAL section above
# 3. Create .env file with required variables
# Copy code from Step 4 in CRITICAL section above
# 4. Clear cache and restart
rmdir /s /q .cache build # Windows
rm -rf .cache build # Mac/Linux
npm run developFor Strapi v5
# 1. Install
npm install strapi-to-lokalise-plugin@latest
# 2. Edit config/plugins.ts
# Add plugin configuration (see CRITICAL section above)
# 3. Restart
npm run develop⚙️ Configuration
Initial Setup
- Navigate to Lokalise Sync in the admin sidebar
- Configure Settings:
- Enter your Lokalise Project ID (found in your Lokalise project settings)
- Enter your Lokalise API Token (create one in Lokalise Account Settings → API tokens)
- Optionally configure the Lokalise Base URL (defaults to
https://api.lokalise.com/api2)
- Test Connection: Click "Test connection" to verify your credentials
- Save Settings: Click "Save settings" to store your configuration
API Token Permissions
Your Lokalise API token needs the following permissions:
- Read - To preview and read translations
- Write - To sync translations back to Lokalise
🚀 Usage
Preview Translations
- Click "Run preview" to see what will be synced
- Review the list of content types, keys, and values
- Use the search bar to filter specific content
- Select individual keys or entire content types using checkboxes
Sync to Lokalise
- After previewing, select the keys you want to sync
- Click "Sync selected keys"
- Enter a tag name (optional, helps organize syncs in Lokalise)
- Select the locale to sync
- Click "Sync now"
- Monitor the progress bar until sync completes
Sync Options
- Select All: Use "Select filtered" to select all visible keys
- Preview Filters: Click "Preview options" to filter by content type, sync status, etc.
- Search: Search by content type, group, key name, key ID, or key value
🐛 Troubleshooting
HTTP 500: "Cannot access 'data2' before initialization"
Solution (Already Fixed in v0.1.51+):
Update to latest version:
npm install strapi-to-lokalise-plugin@latestClear ALL caches:
rmdir /s /q .cache build # Windows rm -rf .cache build # Mac/LinuxClear browser cache:
- Press
Ctrl+Shift+RorCmd+Shift+R
- Press
Restart Strapi:
npm run develop
401 Unauthorized Errors
See "Issue 3: 401 Unauthorized Errors" in the CRITICAL ISSUES section above.
API Connection Fails
Check these:
Valid credentials:
- Verify Project ID is correct
- Verify API token is valid
- Ensure token hasn't expired
Token permissions:
- Token must have Read and Write permissions
- Check in Lokalise: Account Settings → API tokens
Network/firewall:
- Ensure your server can reach
api.lokalise.com
- Ensure your server can reach
Installation Errors
See "Common Mistakes to Avoid" section in the CRITICAL installation guide above.
📋 Peer Dependencies
The plugin relies on the host Strapi project for these packages:
@strapi/strapi: ^4.1.0 || ^5.0.0react: >=17.0.0react-dom: >=17.0.0@strapi/utils: * (provided by Strapi)lodash: * (provided by Strapi)
Optional:
@strapi/plugin-i18n: * (only needed if you use i18n features)
🔧 Advanced Configuration
Environment Variables
You can optionally set a secret key for token encryption:
LOKALISE_SYNC_SECRET_KEY=your-secret-key-hereThis enables AES-256-GCM encryption for stored API tokens.
Custom Lokalise Base URL
If you're using a self-hosted Lokalise instance, set the base URL in plugin settings or via environment:
LOKALISE_BASE_URL=https://your-lokalise-instance.com/api2🤝 Getting Help
Reporting Issues
If you encounter a bug or have a feature request:
- Check the troubleshooting section above
- Check the CRITICAL ISSUES section above
- Create a new issue with:
- Strapi version
- Node.js version
- Plugin version
- Error messages/logs
- Steps to reproduce
📚 Additional Resources
📝 License
MIT License - see LICENSE file for details.
Made with care to ensure smooth installation and zero dependency conflicts across all Strapi versions.
