Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkwinkelmann committed Feb 12, 2021
0 parents commit 415e35b
Show file tree
Hide file tree
Showing 24 changed files with 4,518 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
[*.md]
indent_size = 2
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
js/src export-ignore
.git* export-ignore

js/dist/*.js -diff
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
vendor
composer.lock
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Clark Winkelmann

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.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation Inspector

[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/clarkwinkelmann/flarum-ext-translation-inspector/blob/master/LICENSE.md) [![Latest Stable Version](https://img.shields.io/packagist/v/clarkwinkelmann/flarum-ext-translation-inspector.svg)](https://packagist.org/packages/clarkwinkelmann/flarum-ext-translation-inspector) [![Total Downloads](https://img.shields.io/packagist/dt/clarkwinkelmann/flarum-ext-translation-inspector.svg)](https://packagist.org/packages/clarkwinkelmann/flarum-ext-translation-inspector) [![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.me/clarkwinkelmann)

Enable forum users to find details about translations.

This is an early version of the extension. A future update will allow coupling with a report feature.

Current features:

- A link in the sidebar enables "inspect" mode
- When "inspect" mode is active, all translatable texts are highlighted
- Clicking on a text brings up a modal with details about the translation key, which extension provides it and a link to the source file if it's on GitHub
- The feature is protected by a permission, but the link is currently visible to everyone all the time

> Caution: if you have private extensions or local extenders installed, this extension could expose their repository URLs, names, icons or relative paths to some of their yaml files
## Installation

composer require clarkwinkelmann/flarum-ext-translation-inspector

## Support

This extension is under **minimal maintenance**.

It was developed for a client and released as open-source for the benefit of the community.
I might publish simple bugfixes or compatibility updates for free.

You can [contact me](https://clarkwinkelmann.com/flarum) to sponsor additional features or updates.

Support is offered on a "best effort" basis through the Flarum community thread.

## Links

- [GitHub](https://github.com/clarkwinkelmann/flarum-ext-translation-inspector)
- [Packagist](https://packagist.org/packages/clarkwinkelmann/flarum-ext-translation-inspector)
40 changes: 40 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "clarkwinkelmann/flarum-ext-translation-inspector",
"description": "Enable forum users to find details about translations",
"keywords": [
"flarum"
],
"type": "flarum-extension",
"license": "MIT",
"require": {
"flarum/core": ">=0.1.0-beta.15 <0.1.0-beta.16",
"ext-json": "*"
},
"authors": [
{
"name": "Clark Winkelmann",
"email": "[email protected]",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/clarkwinkelmann/flarum-ext-translation-inspector/issues",
"source": "https://github.com/clarkwinkelmann/flarum-ext-translation-inspector"
},
"autoload": {
"psr-4": {
"ClarkWinkelmann\\TranslationInspector\\": "src/"
}
},
"extra": {
"flarum-extension": {
"title": "Translation Inspector",
"category": "language",
"icon": {
"name": "fas fa-highlighter",
"backgroundColor": "#684ba6",
"color": "#fff"
}
}
}
}
18 changes: 18 additions & 0 deletions extend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace ClarkWinkelmann\TranslationInspector;

use Flarum\Extend;

return [
(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js'),
(new Extend\Frontend('forum'))
->js(__DIR__ . '/js/dist/forum.js')
->css(__DIR__ . '/resources/less/forum.less'),

new Extend\Locales(__DIR__ . '/resources/locale'),

(new Extend\Routes('api'))
->get('/inspect-translation', 'inspect-translation', Controllers\InspectTranslationController::class),
];
1 change: 1 addition & 0 deletions js/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/admin';
2 changes: 2 additions & 0 deletions js/dist/admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/dist/admin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions js/dist/forum.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/dist/forum.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/forum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/forum';
13 changes: 13 additions & 0 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@clarkwinkelmann/translation-inspector",
"private": true,
"dependencies": {
"flarum-webpack-config": "^0.1.0-beta.10",
"webpack": "^4.0.0",
"webpack-cli": "^3.0.7"
},
"scripts": {
"dev": "webpack --mode development --watch",
"build": "webpack --mode production"
}
}
14 changes: 14 additions & 0 deletions js/src/admin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import app from 'flarum/app';

/* global m */

app.initializers.add('clarkwinkelmann-translation-inspector', () => {
app.extensionData
.for('clarkwinkelmann-translation-inspector')
.registerPermission({
icon: 'fas fa-highlighter',
label: app.translator.trans('clarkwinkelmann-translation-inspector.admin.permissions.inspect'),
permission: 'clarkwinkelmann-translation-inspector.inspect',
allowGuest: true,
}, 'view');
});
Loading

0 comments on commit 415e35b

Please sign in to comment.