Skip to content

Commit

Permalink
feat: new framework jeklly support, close #568
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 28, 2021
1 parent 0fea000 commit 6d6f96c
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/by-frameworks/jekyll/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"i18n-ally.localesPaths": ["_i18n"]
}
4 changes: 4 additions & 0 deletions examples/by-frameworks/jekyll/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

gem 'jekyll', github: 'jekyll/jekyll'
gem 'jekyll-multiple-languages-plugin'
21 changes: 21 additions & 0 deletions examples/by-frameworks/jekyll/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Dorian OUAKLI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions examples/by-frameworks/jekyll/_i18n/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
four_hundred_four:
page_not_found: Page not found :(
turn_back_home: Go back home
3 changes: 3 additions & 0 deletions examples/by-frameworks/jekyll/_i18n/fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
four_hundred_four:
page_not_found: Page non trouvée :(
turn_back_home: Retourner à l'accueil
13 changes: 13 additions & 0 deletions examples/by-frameworks/jekyll/_pages/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
layout: default
not_in_footer: true
ref: four_hundred_four
---

<main class="center">
<div class="text-center">
<h1 class="reset-color">404</h1>
<h2 class="reset-color">{% t four_hundred_four.page_not_found %}</h2>
<p><a href="{{ site.baseurl }}/">{% t four_hundred_four.turn_back_home %}</a></p>
</div>
</main>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,8 @@
"next-translate",
"php-gettext",
"general",
"lingui"
"lingui",
"jekyll"
]
},
"description": "%config.enabled_frameworks%"
Expand Down
2 changes: 2 additions & 0 deletions src/frameworks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import NextTranslateFramework from './next-translate'
import PhpGettextFramework from './php-gettext'
import GeneralFramework from './general'
import LinguiFramework from './lingui'
import JekyllFramework from './jekyll'
import i18n from '~/i18n'
import { Log } from '~/utils'

Expand Down Expand Up @@ -55,6 +56,7 @@ export const frameworks: Framework[] = [
new NextTranslateFramework(),
new PhpGettextFramework(),
new LinguiFramework(),
new JekyllFramework(),
new GeneralFramework(),

// Vue SFC should be the last one
Expand Down
32 changes: 32 additions & 0 deletions src/frameworks/jekyll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Framework } from './base'
import { LanguageId } from '~/utils'

class JekyllFramework extends Framework {
id = 'jekyll'
display = 'Jekyll'

detection = {
gemfile: [
'jekyll-multiple-languages-plugin',
],
}

languageIds: LanguageId[] = [
'html',
]

usageMatchRegex = [
'\\{\\%\\s+t\\s+({key})\\s+\\%\\}',
]

perferredKeystyle = 'nested' as const

refactorTemplates(keypath: string) {
return [
`{% t ${keypath} %}`,
keypath,
]
}
}

export default JekyllFramework

0 comments on commit 6d6f96c

Please sign in to comment.