-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fad1204
Showing
28 changed files
with
3,321 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module.exports = { | ||
extends: ["plugin:vue/recommended", "plugin:prettier-vue/recommended", "prettier"], | ||
|
||
settings: { | ||
"prettier-vue": { | ||
// Settings for how to process Vue SFC Blocks | ||
SFCBlocks: { | ||
/** | ||
* Use prettier to process `<template>` blocks or not | ||
* | ||
* If set to `false`, you may need to enable those vue rules that are disabled by `eslint-config-prettier`, | ||
* because you need them to lint `<template>` blocks | ||
* | ||
* @default true | ||
*/ | ||
template: true, | ||
|
||
/** | ||
* Use prettier to process `<script>` blocks or not | ||
* | ||
* If set to `false`, you may need to enable those rules that are disabled by `eslint-config-prettier`, | ||
* because you need them to lint `<script>` blocks | ||
* | ||
* @default true | ||
*/ | ||
script: true, | ||
|
||
/** | ||
* Use prettier to process `<style>` blocks or not | ||
* | ||
* @default true | ||
*/ | ||
style: true, | ||
}, | ||
usePrettierrc: true, | ||
fileInfoOptions: { | ||
withNodeModules: false, | ||
}, | ||
}, | ||
}, | ||
|
||
rules: { | ||
"prettier-vue/prettier": [ | ||
"error", | ||
{ | ||
// Override all options of `prettier` here | ||
// @see https://prettier.io/docs/en/options.html | ||
printWidth: 100, | ||
singleQuote: false, | ||
semi: true, | ||
trailingComma: "es5", | ||
bracketSameLine: true, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: RELEASE | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install | ||
run: npm install | ||
|
||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT_SEMANTIC_RELEASE }} | ||
run: npx semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# OS files | ||
.DS_Store | ||
.iml | ||
.idea | ||
|
||
# npm modules | ||
/node_modules | ||
|
||
# Parcel cache folder | ||
.cache | ||
|
||
# Composer files | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
use Kirby\Data\Json; | ||
use Kirby\Filesystem\Dir; | ||
use Kirby\Filesystem\F; | ||
use Kirby\Http\Response; | ||
|
||
$contentRoot = kirby()->root('content'); | ||
$path = $contentRoot.DS.'localizer'; | ||
$localisations = $contentRoot.DS.'localizer'.DS."localisations.json"; | ||
|
||
return [ | ||
'routes' => [ | ||
[ | ||
'pattern' => '/localizer/translations', | ||
'method' => 'get', | ||
'action' => function () use ($path) { | ||
try { | ||
$files = Dir::read($path); | ||
$data = []; | ||
|
||
foreach ($files as $file) { | ||
$content = F::read($path.DS.$file); | ||
if (F::is($file, 'json')) { | ||
$data[] = Json::decode($content); | ||
} | ||
} | ||
|
||
return Response::json($data); | ||
} catch (Exception $exception) { | ||
return Response::json([]); | ||
} | ||
}, | ||
], | ||
[ | ||
'pattern' => '/localizer/translations', | ||
'method' => 'post', | ||
'action' => function () use ($path) { | ||
$translations = kirby()->request()->body()->data(); | ||
$languages = []; | ||
|
||
foreach ($translations as $translation) { | ||
$id = $translation['language']['id']; | ||
Json::write($path.DS."$id.json", $translation); | ||
|
||
// save language id for deletion check | ||
$languages[] = $id; | ||
} | ||
|
||
// delete removed languages groups | ||
$files = Dir::read($path); | ||
foreach ($files as $file) { | ||
$filename = F::name($file); | ||
if (!in_array($filename, $languages)) { | ||
F::remove($path.DS.$file); | ||
} | ||
} | ||
|
||
return Response::json($translations); | ||
}, | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
return [ | ||
'panel-localizer' => function () { | ||
return [ | ||
'label' => 'Localizer', | ||
'icon' => 'globe', | ||
'menu' => true, | ||
'link' => 'panel-localizer', | ||
'views' => [ | ||
[ | ||
'pattern' => 'panel-localizer', | ||
'action' => function () { | ||
return [ | ||
'component' => 'k-panel-localizer-area', | ||
'title' => 'Localize Panel Translations', | ||
'props' => [], | ||
]; | ||
}, | ||
], | ||
], | ||
]; | ||
}, | ||
]; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "gearsdigital/localizer-for-kirby", | ||
"description": "A plugin to override _Panel_ and _Plugin_ translations.", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"type": "kirby-plugin", | ||
"authors": [ | ||
{ | ||
"name": "Steffen Giers", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.4", | ||
"getkirby/composer-installer": "^1.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"gearsdigital\\localizer\\": "src/" | ||
} | ||
}, | ||
"config": { | ||
"optimize-autoloader": true, | ||
"sort-packages": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Kirby\Data\Json; | ||
use Kirby\Filesystem\Dir; | ||
use Kirby\Filesystem\F; | ||
|
||
return [ | ||
'system.loadPlugins:after' => function () { | ||
$contentRoot = kirby()->root('content'); | ||
$path = $contentRoot.DS.'localizer'; | ||
$files = Dir::read($path); | ||
$translations = []; | ||
|
||
foreach ($files as $file) { | ||
$filePath = $path.DS.$file; | ||
if (!F::exists($filePath)) { | ||
return; | ||
} | ||
|
||
$content = Json::read($filePath); | ||
if (F::is($file, 'json')) { | ||
if (is_array($content['translations']) && count($content['translations']) > 0) { | ||
$translations[$content['language']['id']] = array_map(function ($arr) { | ||
if (array_key_exists('override', $arr) && $arr['override']) { | ||
return [$arr['key'] => $arr['override']]; | ||
} | ||
|
||
return $arr; | ||
}, $content['translations'])[0]; | ||
} | ||
} | ||
} | ||
|
||
kirby()->extend(['translations' => $translations], kirby()->plugin('gearsdigital/kirby-panel-localizer')); | ||
}, | ||
]; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.