From d203251a07b7e6a9dfaacb8145ab8e5db76dd001 Mon Sep 17 00:00:00 2001 From: RostiMelk Date: Sun, 12 Apr 2020 16:58:19 +0200 Subject: [PATCH 01/10] Added support for i18n --- _locales/en/messages.json | 35 +++++++++++++++++++++++++++++++++++ _locales/no/messages.json | 35 +++++++++++++++++++++++++++++++++++ manifest.json | 5 +++-- scripts/app.js | 21 ++++++++++++++------- scripts/misc.js | 10 +++++----- 5 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 _locales/en/messages.json create mode 100644 _locales/no/messages.json diff --git a/_locales/en/messages.json b/_locales/en/messages.json new file mode 100644 index 0000000..ac31f35 --- /dev/null +++ b/_locales/en/messages.json @@ -0,0 +1,35 @@ +{ + "extDescription": { + "message": "Advanced Custom Fields code made simple!" + }, + "copyFieldName": { + "message": "Copy field name to clipboard" + }, + "copiedFieldName": { + "message": "Copied field name to clipboard!" + }, + "openDocsTitle": { + "message": "Open ACF documentation for this field" + }, + "copyCodeBtn": { + "message": "Copy code" + }, + "copyCodeBtnTitle": { + "message": "Copy PHP code for this field" + }, + "copyAllCodeBtn": { + "message": "Copy code with sub fields" + }, + "copyAllCodeBtnTitle": { + "message": "Copy PHP code for this field and inner fields" + }, + "copiedCode": { + "message": "Copied code to clipboard!" + }, + "copiedCodeSub": { + "message": "Copied code with sub fields to clipboard!" + }, + "fieldError": { + "message": "Unsupported field, submit an issue on: https://github.com/RostiMelk/ACF-Tools/issues" + } +} \ No newline at end of file diff --git a/_locales/no/messages.json b/_locales/no/messages.json new file mode 100644 index 0000000..2c6f83c --- /dev/null +++ b/_locales/no/messages.json @@ -0,0 +1,35 @@ +{ + "extDescription": { + "message": "Advanced Custom Fields kode gjort enkelt!" + }, + "copyFieldName": { + "message": "Kopier feltnavn til utklippstavlen" + }, + "copiedFieldName": { + "message": "Kopierte feltnavn til utklippstavlen!" + }, + "openDocsTitle": { + "message": "Åpne ACF dokumentasjonen for denne feltgruppen" + }, + "copyCodeBtn": { + "message": "Kopier kode" + }, + "copyCodeBtnTitle": { + "message": "Kopier PHP koden for dette feltet" + }, + "copyAllCodeBtn": { + "message": "Kopier kode med underfelt" + }, + "copyAllCodeBtnTitle": { + "message": "Kopier PHP koden for dette feltet med underfelt" + }, + "copiedCode": { + "message": "Kopierte koden til utklippstavlen!" + }, + "copiedCodeSub": { + "message": "Kopierte koden med underfelt til utklippstavlen!" + }, + "fieldError": { + "message": "Dette feltet støttes. Send inn en issue her: https://github.com/RostiMelk/ACF-Tools/issues" + } +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 4b62ddb..ad65c94 100755 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,9 @@ { "manifest_version": 2, "name": "ACF Tools", - "version": "2.4.2", - "description": "Advanced Custom Fields code made simple!", + "version": "2.5.0", + "description": "__MSG_extDescription__", + "default_locale": "en", "icons": { "16": "icons/icon16.png", "48": "icons/icon48.png", diff --git a/scripts/app.js b/scripts/app.js index 9426d37..04e7a89 100755 --- a/scripts/app.js +++ b/scripts/app.js @@ -18,15 +18,16 @@ $("body").on('click', function() { function copyFieldName() { $(".acf-tbody .li-field-name").each(function() { if(!$(this).children('.copy-field-name').length) { - var str = $(this).text(); + var str = $(this).text(), + title = chrome.i18n.getMessage('copyFieldName'); $(this).text(''); - $(this).append(''+str+''); + $(this).append(''+str+''); } }) $("body").on("click", ".copy-field-name", function(e) { e.preventDefault(); copyStringToClipboard(this); - copyMessage('Copied field name to clipboard!'); + copyMessage(chrome.i18n.getMessage('copiedFieldName')); }); } @@ -35,10 +36,11 @@ function openDocs() { $(".acf-tbody .li-field-type").each(function() { if(!$(this).children('.open-field-docs').length) { var str = $(this).text(), + title = chrome.i18n.getMessage('openDocsTitle'), slug = $(this).closest('.acf-field-object').attr('data-type').replace("_", "-"), url = "https://www.advancedcustomfields.com/resources/"+slug; $(this).text(''); - $(this).append(''+str+''); + $(this).append(''+str+''); } }) } @@ -46,9 +48,12 @@ function openDocs() { // Copy ACF meta field code feature: function appendCopyCodeBtns() { // Append copy field code button + function appendCopyCodeBtn() { + var btnStr = chrome.i18n.getMessage('copyCodeBtn'), + btnTitle = chrome.i18n.getMessage('copyCodeBtnTitle'); $('.acf-field-object:not([data-type="accordion"], [data-type="message"], [data-type="tab"]) .row-options') - .append('Copy code'); + .append(''+btnStr+''); } appendCopyCodeBtn(); // Append buttons to new fields @@ -61,10 +66,12 @@ function appendCopyCodeBtns() { // Append copy all fields code button function appendCopyAllCodeBtn() { + var btnStr = chrome.i18n.getMessage('copyAllCodeBtn'), + btnTitle = chrome.i18n.getMessage('copyAllCodeBtnTitle'); $('.acf-field-object[data-type="repeater"], .acf-field-object[data-type="group"]') .children(".handle") .find(".row-options") - .append('Copy code with sub fields'); + .append(''+btnStr+''); } appendCopyAllCodeBtn(); @@ -190,7 +197,7 @@ function appendFieldNameOnEdit() { }); $('body').on('click', '.post-edit-field-name-info', function(e) { e.preventDefault(); - copyMessage('Copied field name to clipboard!'); + copyMessage(chrome.i18n.getMessage('copiedFieldName')); copyStringToClipboard($(this)); }) } \ No newline at end of file diff --git a/scripts/misc.js b/scripts/misc.js index 6e07508..4440c3a 100644 --- a/scripts/misc.js +++ b/scripts/misc.js @@ -30,13 +30,13 @@ function copyCodeToClipboard(fieldCode, subFields) { temp.remove(); if(subFields.length) { - copyMessage('Copied code with sub fields to clipboard!'); + copyMessage(chrome.i18n.getMessage('copiedCodeSub')); } else { - copyMessage('Copied code to clipboard!'); + copyMessage(chrome.i18n.getMessage('copiedCode')); } } function fieldError() { - alert("Unsupported field, submit an issue on: \nhttps://github.com/RostiMelk/ACF-Tools"); - throw new Error("Unsupported field, submit an issue on: https://github.com/RostiMelk/ACF-Tools"); -} \ No newline at end of file + alert(chrome.i18n.getMessage('fieldError')); + throw new Error(chrome.i18n.getMessage('fieldError')); +} From b1eb08e437509b217ddd979ed01821afa7d0598c Mon Sep 17 00:00:00 2001 From: RostiMelk Date: Sun, 12 Apr 2020 17:20:33 +0200 Subject: [PATCH 02/10] Moved extension into src folder and added a building script --- .gitignore | 2 ++ build.sh | 16 ++++++++++++++++ {_locales => src/_locales}/en/messages.json | 0 {_locales => src/_locales}/no/messages.json | 0 {icons => src/icons}/icon128.png | Bin {icons => src/icons}/icon16.png | Bin {icons => src/icons}/icon48.png | Bin {lib => src/lib}/jquery-3.4.1.min.js | 0 manifest.json => src/manifest.json | 0 {scripts => src/scripts}/app.js | 0 {scripts => src/scripts}/fields.js | 0 {scripts => src/scripts}/misc.js | 0 {styles => src/styles}/style.css | 0 13 files changed, 18 insertions(+) create mode 100644 build.sh rename {_locales => src/_locales}/en/messages.json (100%) rename {_locales => src/_locales}/no/messages.json (100%) rename {icons => src/icons}/icon128.png (100%) rename {icons => src/icons}/icon16.png (100%) rename {icons => src/icons}/icon48.png (100%) rename {lib => src/lib}/jquery-3.4.1.min.js (100%) rename manifest.json => src/manifest.json (100%) rename {scripts => src/scripts}/app.js (100%) rename {scripts => src/scripts}/fields.js (100%) rename {scripts => src/scripts}/misc.js (100%) rename {styles => src/styles}/style.css (100%) diff --git a/.gitignore b/.gitignore index e43b0f9..0e32ed1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .DS_Store +dist/ +*.zip \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..7939b47 --- /dev/null +++ b/build.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +NAME="acf-tools" +VERSION=$(jq -r .version src/manifest.json) + +mkdir -p dist +rm dist/*.zip + +# for Chrome +zip -r "dist/${NAME}-${VERSION}-chrome.zip" src -x "*.DS_Store" + +# for Firefox +cd src +zip -r "../dist/${NAME}-${VERSION}-firefox.zip" * -x "*.DS_Store" + +echo 'Finished build!' \ No newline at end of file diff --git a/_locales/en/messages.json b/src/_locales/en/messages.json similarity index 100% rename from _locales/en/messages.json rename to src/_locales/en/messages.json diff --git a/_locales/no/messages.json b/src/_locales/no/messages.json similarity index 100% rename from _locales/no/messages.json rename to src/_locales/no/messages.json diff --git a/icons/icon128.png b/src/icons/icon128.png similarity index 100% rename from icons/icon128.png rename to src/icons/icon128.png diff --git a/icons/icon16.png b/src/icons/icon16.png similarity index 100% rename from icons/icon16.png rename to src/icons/icon16.png diff --git a/icons/icon48.png b/src/icons/icon48.png similarity index 100% rename from icons/icon48.png rename to src/icons/icon48.png diff --git a/lib/jquery-3.4.1.min.js b/src/lib/jquery-3.4.1.min.js similarity index 100% rename from lib/jquery-3.4.1.min.js rename to src/lib/jquery-3.4.1.min.js diff --git a/manifest.json b/src/manifest.json similarity index 100% rename from manifest.json rename to src/manifest.json diff --git a/scripts/app.js b/src/scripts/app.js similarity index 100% rename from scripts/app.js rename to src/scripts/app.js diff --git a/scripts/fields.js b/src/scripts/fields.js similarity index 100% rename from scripts/fields.js rename to src/scripts/fields.js diff --git a/scripts/misc.js b/src/scripts/misc.js similarity index 100% rename from scripts/misc.js rename to src/scripts/misc.js diff --git a/styles/style.css b/src/styles/style.css similarity index 100% rename from styles/style.css rename to src/styles/style.css From c79c5818967cdd82f647c3496205e8467fcbce50 Mon Sep 17 00:00:00 2001 From: RostiMelk Date: Sun, 12 Apr 2020 17:34:28 +0200 Subject: [PATCH 03/10] Only run build file if jq is installed --- build.sh | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index 7939b47..a1f2ae3 100644 --- a/build.sh +++ b/build.sh @@ -1,16 +1,30 @@ #!/bin/bash -NAME="acf-tools" -VERSION=$(jq -r .version src/manifest.json) +# Colors +error='\033[0;31m' +warning='\033[0;33m' +success='\033[0;32m' +end='\033[0m' -mkdir -p dist -rm dist/*.zip +if brew ls --versions jq > /dev/null; then + NAME="acf-tools" + VERSION=$(jq -r .version src/manifest.json) -# for Chrome -zip -r "dist/${NAME}-${VERSION}-chrome.zip" src -x "*.DS_Store" + mkdir -p dist + rm dist/*.zip -# for Firefox -cd src -zip -r "../dist/${NAME}-${VERSION}-firefox.zip" * -x "*.DS_Store" + # for Chrome + zip -r "dist/${NAME}-v${VERSION}-chrome.zip" src -x "*.DS_Store" + + # for Firefox + cd src + zip -r "../dist/${NAME}-v${VERSION}-firefox.zip" * -x "*.DS_Store" + + echo "" + echo "${success}✅ Finished build!${end}" +else + echo "" + echo "${error}❌ package jq not found.${end}" + echo "${warning}Try running: brew install jq${end}" +fi -echo 'Finished build!' \ No newline at end of file From b97f09e29c1d83f54a0d8fe045b641308f180234 Mon Sep 17 00:00:00 2001 From: RostiMelk Date: Sun, 12 Apr 2020 17:41:13 +0200 Subject: [PATCH 04/10] Update Firefox dev instructions in readme --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 818725f..a2a3b1f 100755 --- a/README.md +++ b/README.md @@ -39,9 +39,13 @@ You can [find the extension in the Firefox add-on libary](https://addons.mozilla ### Mozilla Firefox 1. Clone repo -2. Go to about:debugging -3. Click "Load Temporary Add-on" -4. Refresh Firefox Add-on to test and debug as you develop +2. cd into ACF-Tools folder +3. Build Project with $ sh build.sh +4. Go to about:debugging +5. Click "This Firefox" +6. Click "Load Temporary Add-on" +7. Navigate into ACF-Tools/dist +8. Select acf-tools-vX.X.X-firefox.zip to test --- From 41e7a27981416c5bd86e4fd45924db15580ee987 Mon Sep 17 00:00:00 2001 From: RostiMelk Date: Sun, 12 Apr 2020 17:44:06 +0200 Subject: [PATCH 05/10] Added guide for contributing translations --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index a2a3b1f..f8103f0 100755 --- a/README.md +++ b/README.md @@ -26,6 +26,17 @@ You can [find the extension in the Firefox add-on libary](https://addons.mozilla --- +## Contributing + +### Translation +I need your help with translations + +1. Fork this repository. +2. Edit `messages.json` in `src/_locales/[localeCode]`. If it does not already exist, create a directory according to the [supported locales](https://developer.chrome.com/webstore/i18n?csw=1#localeTable). +3. Create a new pull request. + +--- + ## Development setup ### Google Chrome From 6e4e1a31a9a1906cf45fb07978703ba5210df100 Mon Sep 17 00:00:00 2001 From: RostiMelk Date: Sun, 12 Apr 2020 17:46:32 +0200 Subject: [PATCH 06/10] Minor fixes in readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f8103f0..7089a29 100755 --- a/README.md +++ b/README.md @@ -42,21 +42,21 @@ I need your help with translations ### Google Chrome 1. Clone repo -2. Go to chrome://extensions/ -3. Drag and drop folder into this window +2. Go to `chrome://extensions/` +3. Drag and drop the `src` folder into this window 4. Write code 5. Refresh Chrome Extension to test and debug as you develop ### Mozilla Firefox 1. Clone repo -2. cd into ACF-Tools folder +2. cd into `ACF-Tools` folder 3. Build Project with $ sh build.sh -4. Go to about:debugging +4. Go to `about:debugging` 5. Click "This Firefox" 6. Click "Load Temporary Add-on" 7. Navigate into ACF-Tools/dist -8. Select acf-tools-vX.X.X-firefox.zip to test +8. Select `acf-tools-vX.X.X-firefox.zip` to test --- From d948a81d0adf522b10b24ceb730972692ec86d67 Mon Sep 17 00:00:00 2001 From: RostiMelk Date: Sun, 12 Apr 2020 17:47:02 +0200 Subject: [PATCH 07/10] Minor fixes in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7089a29..c99cf16 100755 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ I need your help with translations 1. Clone repo 2. cd into `ACF-Tools` folder -3. Build Project with $ sh build.sh +3. Build Project with `$ sh build.sh` 4. Go to `about:debugging` 5. Click "This Firefox" 6. Click "Load Temporary Add-on" From 48343959db3febfbee6d738969a2e39a0e5a9bbd Mon Sep 17 00:00:00 2001 From: RostiMelk Date: Sun, 12 Apr 2020 18:04:47 +0200 Subject: [PATCH 08/10] added table of content --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c99cf16..cf35419 100755 --- a/README.md +++ b/README.md @@ -4,6 +4,22 @@ [![Google Web Store version](https://img.shields.io/chrome-web-store/v/ogliegjmpalokmaaeckcdgbhdeedcnmf)](https://chrome.google.com/webstore/detail/acf-tools/ogliegjmpalokmaaeckcdgbhdeedcnmf) [![Mozilla Firefox add-on libary version](https://img.shields.io/amo/v/ACF-Tools?color=orange)](https://addons.mozilla.org/en-US/firefox/addon/acf-tools/) +## Table of content + +- [What does it do?](#but-what-does-it-do) +- [Installation](#installation) + - [Chrome Web Store](#chrome-web-store) + - [Firefox browser add-ons](#firefox-browser-add-ons) +- [Contributing](#contributing) + - [Translation](#translation) +- [Development setup](#development-setup) + - [Google Chrome](#google-chrome) + - [Mozilla Firefox](#mozilla-firefox) +- [Contact Details](#contact-details) +- [License](#license) + +--- + This is a Google Chrome extension/Firefox add-on for Advanced Custom Fields to help with speeding up development. 🔥 ### But what does it do? @@ -66,4 +82,8 @@ Rostislav Melkumyan - @RostiMelk - hello@rosti.no \ Project Link: https://github.com/RostiMelk/ACF-Tools \ Feeling generous? Donations are accepted on paypal: hello@rosti.no -Distributed under the MIT license. See LICENSE for more information. +--- + +## License + +Distributed under the MIT license. See `LICENSE` for more information. From 4aa4ea8defc1c268d92ee3ec66180fe57609a73c Mon Sep 17 00:00:00 2001 From: RostiMelk Date: Sun, 12 Apr 2020 18:06:33 +0200 Subject: [PATCH 09/10] added table of content --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf35419..272203c 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ![ACF Tools - Advanced Custom Fields code made simple](https://user-images.githubusercontent.com/25268506/79060144-bd7e0700-7c81-11ea-958f-4de9aff2bc01.jpg) +This is a Google Chrome extension/Firefox add-on for Advanced Custom Fields to help with speeding up development. 🔥 + [![License](http://img.shields.io/:license-mit-semigreen.svg)](https://opensource.org/licenses/MIT) [![Google Web Store version](https://img.shields.io/chrome-web-store/v/ogliegjmpalokmaaeckcdgbhdeedcnmf)](https://chrome.google.com/webstore/detail/acf-tools/ogliegjmpalokmaaeckcdgbhdeedcnmf) [![Mozilla Firefox add-on libary version](https://img.shields.io/amo/v/ACF-Tools?color=orange)](https://addons.mozilla.org/en-US/firefox/addon/acf-tools/) @@ -20,7 +22,6 @@ --- -This is a Google Chrome extension/Firefox add-on for Advanced Custom Fields to help with speeding up development. 🔥 ### But what does it do? From 34e9c49b4a210849c18a60734a19ec54ad6ffe18 Mon Sep 17 00:00:00 2001 From: Rene Date: Sun, 12 Apr 2020 19:15:10 +0200 Subject: [PATCH 10/10] added de - german --- .gitignore | 3 ++- src/_locales/de/messages.json | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/_locales/de/messages.json diff --git a/.gitignore b/.gitignore index 0e32ed1..4499ced 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store dist/ -*.zip \ No newline at end of file +*.zip +.idea \ No newline at end of file diff --git a/src/_locales/de/messages.json b/src/_locales/de/messages.json new file mode 100644 index 0000000..ce28c03 --- /dev/null +++ b/src/_locales/de/messages.json @@ -0,0 +1,35 @@ +{ + "extDescription": { + "message": "Advanced Custom Fields Code einfach gemacht!" + }, + "copyFieldName": { + "message": "Feldname in Zwischenablage kopieren" + }, + "copiedFieldName": { + "message": "Feldname in Zwischenablage kopiert!" + }, + "openDocsTitle": { + "message": "Öffne die ACF Dokumentation für dieses Feld" + }, + "copyCodeBtn": { + "message": "Code kopieren" + }, + "copyCodeBtnTitle": { + "message": "PHP Code für dieses Feld kopieren" + }, + "copyAllCodeBtn": { + "message": "Code mit Unterfeldern kopieren" + }, + "copyAllCodeBtnTitle": { + "message": "PHP Code für dieses Feld und Unterfelder kopieren" + }, + "copiedCode": { + "message": "Code in Zwischenablage kopiert!" + }, + "copiedCodeSub": { + "message": "Code mit Unterfeldern in Zwischenablage kopiert!" + }, + "fieldError": { + "message": "Nicht unterstütztes Feld, reiche hier ein Issue ein: https://github.com/RostiMelk/ACF-Tools/issues" + } +} \ No newline at end of file