Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sahinvardar committed May 30, 2023
0 parents commit b82c34d
Show file tree
Hide file tree
Showing 26 changed files with 2,501 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish to NPM
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v2
- run: pnpm install
- run: pnpm build
- run: pnpm test
- run: pnpm -r publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
134 changes: 134 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
.DS_Store
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

lib

26 changes: 26 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# misc
.DS_Store
.gitignore
.husky
.npmrc
.nvmrc

# ide
.idea/
.vscode/

# dependencies
node_modules/

# build
tsconfig.tsbuildinfo
lib/
dist/

# cdk
cdk.outputs.json
cdk.out/

# pnpm
pnpm-lock.yaml
pnpm-workspace.yaml
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"printWidth": 120,
"arrowParens": "avoid",
"plugins": ["prettier-plugin-organize-imports"],
"trailingComma": "none"
}
11 changes: 11 additions & 0 deletions assets/example/components/auth.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div>
<span>
{$i18n('firstName')}
</span>
<span>
{$i18n('lastName')}
</span>
<span>
{$i18n('password')}
</span>
</div>
4 changes: 4 additions & 0 deletions assets/example/components/user-form.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Form>
<Input name="firstName"/>
<Input name="lastName"/>
</Form>
3 changes: 3 additions & 0 deletions assets/example/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<slot>
{$i18n('header')}
</slot>
8 changes: 8 additions & 0 deletions assets/example/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<main>
<section>
{$i18n('intro')}
</section>
<section>
{$i18n('known-from',{ param:'hello'})}
</section>
</main>
5 changes: 5 additions & 0 deletions assets/example/routes/about/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<main>
<section>
{$i18n('intro')}
</section>
</main>
5 changes: 5 additions & 0 deletions assets/example/routes/team/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<main>
<section>
{$i18n('team-intro')}
</section>
</main>
10 changes: 10 additions & 0 deletions assets/translations/de.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
translation.components.auth.firstName;xxxTODOxxx
translation.components.auth.lastName;xxxTODOxxx
translation.components.auth.password;xxxTODOxxx
translation.components.user-form.firstName;xxxTODOxxx
translation.components.user-form.lastName;xxxTODOxxx
translation.routes.about.page.intro;xxxTODOxxx
translation.routes.layout.header;xxxTODOxxx
translation.routes.page.intro;xxxTODOxxx
translation.routes.page.known-from;xxxTODOxxx
translation.routes.team.page.team-intro;xxxTODOxxx
10 changes: 10 additions & 0 deletions assets/translations/en.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
translation.components.auth.firstName;xxxTODOxxx
translation.components.auth.lastName;xxxTODOxxx
translation.components.auth.password;xxxTODOxxx
translation.components.user-form.firstName;xxxTODOxxx
translation.components.user-form.lastName;xxxTODOxxx
translation.routes.about.page.intro;xxxTODOxxx
translation.routes.layout.header;xxxTODOxxx
translation.routes.page.intro;xxxTODOxxx
translation.routes.page.known-from;xxxTODOxxx
translation.routes.team.page.team-intro;xxxTODOxxx
33 changes: 33 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env node

import { program } from 'commander';
import { isInSync, synchronies } from '../lib/cli.js';

program.name('svelte-i18next');
program
.command('synchronies')
.description('synchronies all translations keys from the given svelte app with translation files')
.requiredOption('--dirs <string...>', 'path to svelte apps')
.requiredOption('--languages <string...>')
.requiredOption('--output <string>')
.action(async options => {
await synchronies(options);
});

program
.command('in-sync')
.description('check if all keys are in sync')
.requiredOption('--dirs <string...>', 'path to svelte apps')
.requiredOption('--languages <string...>')
.requiredOption('--output <string>')
.action(async options => {
const inSync = await isInSync(options);
if (inSync) {
console.log('Translations keys are in sync');
process.exit(0);
} else {
process.exit(1);
}
});

program.parse();
56 changes: 56 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@vardario/svelte-i18next",
"version": "0.1.0",
"description": "",
"license": "MIT",
"author": "Sahin Vardar",
"type": "module",
"main": "lib/index.js",
"bin": {
"svelte-i18next": "./bin/cli.js"
},
"files": [
"/lib",
"!/**/*.map",
"!/**/*.test.*"
],
"scripts": {
"build": "tsc --build",
"format": "prettier --plugin-search-dir . --write . && prettier-package-json --write",
"preinstall": "npx only-allow pnpm",
"test": "vitest run",
"watch": "tsc --watch"
},
"dependencies": {
"@types/lodash": "^4.14.195",
"@vardario/svelte-ast-printer": "^0.1.3",
"acorn": "^8.8.2",
"commander": "^10.0.1",
"csv-parse": "^5.4.0",
"csv-stringify": "^6.4.0",
"lodash": "^4.17.21",
"svelte": "3.59.1",
"typescript": "^5.0.4"
},
"devDependencies": {
"@types/estree": "^1.0.1",
"@types/node": "^20.2.5",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8",
"prettier-package-json": "^2.8.0",
"prettier-plugin-organize-imports": "^3.2.2",
"typescript": "^5.0.4",
"vitest": "^0.31.1"
},
"keywords": [],
"lint-staged": {
"*": "prettier --write --ignore-unknown",
"package.json": "prettier-package-json --write"
},
"repository": {
"type": "git",
"url": "[email protected]:vardario/svelte-i18next.git"
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit b82c34d

Please sign in to comment.