Created
May 2, 2021 08:20
-
-
Save endenwer/7cdb94e51be0d1993458cb7620cca1f9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ;;; init-taxdome.el --- -*- lexical-binding: t -*- | |
| (defcustom taxdome-frontend-en-yml "/Users/stepanlusnikov/projects/taxdome/config/locales/en/frontend.en.yml" | |
| "Full path to locale file" | |
| :group 'taxdome) | |
| (defun get-file-scope () | |
| (save-excursion | |
| (save-match-data | |
| (goto-char (point-min)) | |
| (re-search-forward "scopedTranslation\(\\(?:'\\(.*\\)'\\)\)" nil t 1) | |
| (match-string-no-properties 1)))) | |
| (defun get-current-scope () | |
| (let (p1 | |
| p2 | |
| (case-fold-search t)) | |
| (save-excursion | |
| (skip-chars-backward "_a-z\." ) | |
| (setq p1 (point)) | |
| (skip-chars-forward "_a-z\." ) | |
| (setq p2 (point)) | |
| (buffer-substring-no-properties p1 p2)))) | |
| (defun find-locale () | |
| (interactive) | |
| (let ((scope (concat (get-file-scope) "." (get-current-scope)))) | |
| (switch-to-buffer (find-file-noselect taxdome-frontend-en-yml nil nil nil)) | |
| (goto-char (point-min)) | |
| (dolist (name (split-string scope "\\.")) (search-forward name)))) | |
| (provide 'init-taxdome) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment