├── .editorconfig ├── .github ├── config.yml ├── issue_template.md ├── pull_request_template.md ├── release-drafter.yml ├── stale.yml ├── support.yml └── workflows │ └── add-to-project.yml ├── .scrutinizer.yml ├── .styleci.yml ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json ├── phpunit.xml ├── src ├── LangFileManagerServiceProvider.php ├── app │ ├── Http │ │ ├── Controllers │ │ │ └── LanguageCrudController.php │ │ └── Requests │ │ │ └── LanguageRequest.php │ ├── Models │ │ └── Language.php │ └── Services │ │ └── LangFiles.php ├── config │ └── backpack │ │ └── langfilemanager.php ├── database │ ├── migrations │ │ ├── 2015_09_07_190535_create_languages_table.php │ │ └── 2015_09_10_124414_alter_languages_table.php │ └── seeds │ │ └── LanguageTableSeeder.php ├── resources │ ├── lang │ │ ├── ar │ │ │ └── langfilemanager.php │ │ ├── de │ │ │ └── langsfilemanager.php │ │ ├── en │ │ │ └── langfilemanager.php │ │ ├── es │ │ │ └── langfilemanager.php │ │ ├── fa │ │ │ └── langfilemanager.php │ │ ├── id │ │ │ └── langfilemanager.php │ │ ├── it │ │ │ └── langfilemanager.php │ │ ├── pt │ │ │ └── langfilemanager.php │ │ ├── pt_br │ │ │ └── langfilemanager.php │ │ ├── tr │ │ │ └── langfilemanager.php │ │ ├── vi │ │ │ └── langfilemanager.php │ │ └── zh-cn │ │ │ └── langfilemanager.php │ └── views │ │ ├── button.blade.php │ │ ├── language_headers.blade.php │ │ ├── language_inputs.blade.php │ │ └── translations.blade.php └── routes │ └── backpack │ └── langfilemanager.php └── tests └── LanguageCrudControllerTest.php /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | # Configuration for welcome - https://github.com/behaviorbot/welcome 2 | 3 | # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome 4 | 5 | # Comment to be posted to on first time issues 6 | newIssueWelcomeComment: > 7 | Hello there! Thanks for opening your first issue on this repo! 8 | 9 | 10 | Just a heads-up: **Here at Backpack we use Github Issues only for tracking bugs**. Talk about new features is also acceptable. This helps _a lot_ in keeping our focus on improving Backpack. **If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below)**. If you're not sure where it fits, it's ok, a community member will probably reply to help you with that. 11 | 12 | 13 | Backpack communication mediums: 14 | - Bug Reports, Feature Requests - Github Issues (here); 15 | - Quick help (_How do I do X_) - [Gitter Chatroom](gitter.im/BackpackForLaravel/Lobby); 16 | - Long questions (_I have done X and Y and it won't do Z wtf_) - [Stackoverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel), using the ```backpack-for-laravel``` tag; 17 | 18 | 19 | Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. 20 | 21 | 22 | Thank you! 23 | 24 | 25 | -- 26 | 27 | Justin Case 28 | 29 | The Backpack Robot 30 | 31 | # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome 32 | 33 | # Comment to be posted to on PRs from first time contributors in your repository 34 | newPRWelcomeComment: > 35 | BOOM! Your first PR with us, thank you so much! Someone will take a look at it shortly. 36 | 37 | 38 | Please keep in mind that: 39 | - **if this constitutes a breaking change, it might take quite a while for this to get merged**; we try to emulate the Laravel release cycle as much as possible, so developers can upgrade both software once; this means a new big release every ~6 months; 40 | - **even if it's a non-breaking change, it might take a few days/weeks for the PR to get merged**; unless it's a no-brainer, **we like to have some community feedback on new features, before we merge them**; this leads to higher-quality code, in the end; we learnt this the hard way :-) 41 | - **not all PRs get merged**; sometimes we just have to hold out new features, to keep the packages lean; sometimes we don't include features that only apply to niche use cases; 42 | - **we're not perfect**; if you think we're wrong, call us out on it; but in a kind way :-) we all make mistakes, best we learn from them and build better software together; 43 | 44 | 45 | Thank you! 46 | 47 | 48 | -- 49 | 50 | Justin Case 51 | 52 | The Backpack Robot 53 | 54 | # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge 55 | 56 | # Comment to be posted to on pull requests merged by a first time user 57 | firstPRMergeComment: > 58 | WHOOP-WHOOP! Congrats, your first PR on this repo has officialy been merged. 59 | 60 | 61 | ![party](https://media1.giphy.com/media/3KC2jD2QcBOSc/giphy.gif "Party!!!") 62 | 63 | 64 | If you want to help out the community in other ways, you can: 65 | - **give your opinion on other Github Issues & PRs**; 66 | - **chat with others** in the [Gitter Chatroom](gitter.im/BackpackForLaravel/Lobby) (usually for quick help: _How do I do X_); 67 | - **answer Backpack questions on [Stackoverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel)**; you get points, people get help; you can subscribe to the ```backpack-for-laravel``` tag by [adding a new filter](https://stackexchange.com/filters/256210/my-filter-3); that will send you emails when new questions come up with our tag; 68 | 69 | 70 | Again. Thank you for the PR. You are a wonderful person. Keep 'em coming :-) 71 | 72 | Cheers! 73 | 74 | 75 | -- 76 | 77 | Justin Case 78 | 79 | The Backpack Robot 80 | 81 | 82 | P.S. **Help in the Backpack community is rewarded with free Backpack commercial licenses**. It's the least we can do. If you feel you've helped the community with PRs, help & other stuff, please [shoot Tabacitu an email](mailto:hello@tabacitu.ro) and ask him if you qualify for free licenses. You scratch my back, I scratch your back. Thank you! 83 | 84 | # It is recommend to include as many gifs and emojis as possible 85 | # 86 | # --------------------------------------------------------------------------------------------- 87 | # 88 | # Configuration for request-info - https://github.com/behaviorbot/request-info 89 | 90 | # *OPTIONAL* Comment to reply with 91 | # Can be either a string : 92 | requestInfoReplyComment: > 93 | Hi there! 94 | 95 | 96 | Could you please provide us with more info about this? Looks like you skipped the title/body. 97 | 98 | 99 | Thank you! 100 | 101 | 102 | -- 103 | 104 | Justin Case 105 | 106 | The Backpack Robot 107 | 108 | # Or an array: 109 | # requestInfoReplyComment: 110 | # - Ah no! young blade! That was a trifle short! 111 | # - Tell me more ! 112 | # - I am sure you can be more effusive 113 | 114 | 115 | # *OPTIONAL* default titles to check against for lack of descriptiveness 116 | # MUST BE ALL LOWERCASE 117 | requestInfoDefaultTitles: 118 | # - update readme.md 119 | - updates 120 | 121 | # *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given 122 | requestInfoLabelToAdd: needs-more-info 123 | 124 | # *OPTIONAL* Only warn about insufficient information on these events type 125 | # Keys must be lowercase. Valid values are 'issue' and 'pullRequest' 126 | requestInfoOn: 127 | pullRequest: true 128 | issue: true 129 | 130 | # *OPTIONAL* Add a list of people whose Issues/PRs will not be commented on 131 | # keys must be GitHub usernames 132 | requestInfoUserstoExclude: 133 | - tabacitu 134 | 135 | # --------------------------------------------------------------------------------------------- 136 | # 137 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | # Bug report 2 | 3 | ### What I did: 4 | 5 | ### What I expected to happen: 6 | 7 | ### What happened: 8 | 9 | ### What I've already tried to fix it: 10 | 11 | ### Backpack, Laravel, PHP, DB version: 12 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## WHY 2 | 3 | ### BEFORE - What was wrong? What was happening before this PR? 4 | 5 | ?? 6 | 7 | ### AFTER - What is happening after this PR? 8 | 9 | ?? 10 | 11 | 12 | ## HOW 13 | 14 | ### How did you achieve that, in technical terms? 15 | 16 | ?? 17 | 18 | 19 | 20 | ### Is it a breaking change or non-breaking change? 21 | 22 | ?? 23 | 24 | 25 | ### How can we test the before & after? 26 | 27 | ?? 28 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | # branches to consider in the event; optional, defaults to all 6 | branches: 7 | - master 8 | 9 | jobs: 10 | update_release_draft: 11 | runs-on: ubuntu-latest 12 | steps: 13 | # Drafts your next Release notes as Pull Requests are merged into "master" 14 | - uses: release-drafter/release-drafter@v5 15 | env: 16 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 17 | 18 | name-template: '$NEXT_PATCH_VERSION 🌈' 19 | tag-template: '$NEXT_PATCH_VERSION' 20 | categories: 21 | - title: '🚀 Features' 22 | labels: 23 | - 'feature' 24 | - 'enhancement' 25 | - 'added' 26 | - title: '🐛 Bug Fixes' 27 | labels: 28 | - 'fix' 29 | - 'bugfix' 30 | - 'bug' 31 | - 'fixed' 32 | - title: '⚙️ Changes' 33 | labels: 34 | - 'changed' 35 | - 'dependencies' 36 | - title: '🧰 Removed' 37 | label: 'removed' 38 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' 39 | template: | 40 | ## Changes 41 | $CHANGES 42 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | ##################################### 2 | # Github Stale Probot Configuration # 3 | # ################################### 4 | # https://probot.github.io/apps/stale/ 5 | 6 | # Number of days of inactivity before an issue becomes stale 7 | daysUntilStale: 60 8 | # Number of days of inactivity before a stale issue is closed 9 | daysUntilClose: 14 10 | # Issues with these labels will never be considered stale 11 | exemptLabels: 12 | - pinned 13 | - security 14 | - feature 15 | - urgent 16 | - ready 17 | - working on it 18 | - bug 19 | 20 | # Label to use when marking an issue as stale 21 | staleLabel: stale 22 | # Comment to post when marking an issue as stale. Set to `false` to disable 23 | markComment: > 24 | Hi there! 25 | 26 | 27 | **Is this still an issue?** No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it. 28 | 29 | 30 | Thank you! 31 | 32 | 33 | -- 34 | 35 | Justin Case 36 | 37 | The Backpack Robot 38 | 39 | # Comment to post when closing a stale issue. Set to `false` to disable 40 | closeComment: true 41 | -------------------------------------------------------------------------------- /.github/support.yml: -------------------------------------------------------------------------------- 1 | # Configuration for support-requests - https://github.com/dessant/support-requests 2 | 3 | # Label used to mark issues as support requests 4 | supportLabel: Ask-It-On-Stack-Overflow 5 | # Comment to post on issues marked as support requests. Add a link 6 | # to a support page, or set to `false` to disable 7 | supportComment: > 8 | Oups! 9 | 10 | 11 | Looks like this is a support request, not a bug/feature. **Could you please [repost on StackOverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel), using the ```backpack-for-laravel``` tag**? 12 | 13 | 14 | Background: **Here at Backpack we use Github Issues only for tracking bugs and features**, not individual implementation issues. This helps _a lot_ in keeping our focus on improving Backpack. Thanks a lot for understanding! 15 | 16 | 17 | Here are all the Backpack communication mediums: 18 | - Long questions (_I have done X and Y and it won't do Z wtf_) - [Stackoverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel), using the ```backpack-for-laravel``` tag; this is recommended for most questions, since other developers can then find the answer on a simple Google search; also, people get points for answering - and who doesn't like StackOverflow points?! 19 | - Quick help (_How do I do X_) - [Gitter Chatroom](https://gitter.im/BackpackForLaravel/Lobby); 20 | - Bug Reports, Feature Requests - Github Issues (here); 21 | 22 | Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or StackOverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. 23 | 24 | 25 | Thank you! 26 | 27 | 28 | -- 29 | 30 | Justin Case 31 | 32 | The Backpack Robot 33 | 34 | 35 | PS. In case I mistakenly closed your issue, yell :-) I'm a robot, I make mistakes. 36 | 37 | # Whether to close issues marked as support requests 38 | close: true 39 | # Whether to lock issues marked as support requests 40 | lock: false 41 | -------------------------------------------------------------------------------- /.github/workflows/add-to-project.yml: -------------------------------------------------------------------------------- 1 | name: Add new bugs & PRs to This Week project 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | - transferred 8 | pull_request: 9 | types: 10 | - opened 11 | 12 | jobs: 13 | add-to-project: 14 | name: Add new bugs and PRs to This Week project 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/add-to-project@main 18 | with: 19 | project-url: https://github.com/orgs/Laravel-Backpack/projects/13 20 | github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} 21 | -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | filter: 2 | paths: 3 | - 'app/*' 4 | - 'src/*' 5 | excluded_paths: 6 | - 'bootstrap/*' 7 | - 'config/*' 8 | - 'public/*' 9 | - 'resources/*' 10 | - 'vendor/*' 11 | - 'views/*' 12 | tools: 13 | php_analyzer: true 14 | php_mess_detector: true 15 | php_changetracking: true 16 | php_code_sniffer: 17 | config: 18 | standard: PSR2 19 | php_loc: 20 | excluded_dirs: 21 | - vendor 22 | php_pdepend: 23 | excluded_dirs: 24 | - vendor 25 | - tests 26 | checks: 27 | php: 28 | code_rating: true 29 | duplication: true 30 | variable_existence: true 31 | useless_calls: true 32 | use_statement_alias_conflict: true 33 | unused_variables: true 34 | unused_properties: true 35 | unused_parameters: true 36 | unused_methods: true 37 | unreachable_code: true 38 | sql_injection_vulnerabilities: true 39 | security_vulnerabilities: true 40 | precedence_mistakes: true 41 | precedence_in_conditions: true 42 | parameter_non_unique: true 43 | no_property_on_interface: true 44 | no_non_implemented_abstract_methods: true 45 | deprecated_code_usage: true 46 | closure_use_not_conflicting: true 47 | closure_use_modifiable: true 48 | avoid_useless_overridden_methods: true 49 | avoid_conflicting_incrementers: true 50 | assignment_of_null_return: true 51 | verify_property_names: true 52 | verify_argument_usable_as_reference: true 53 | verify_access_scope_valid: true 54 | use_self_instead_of_fqcn: true 55 | too_many_arguments: true 56 | symfony_request_injection: true 57 | switch_fallthrough_commented: true 58 | spacing_of_function_arguments: true 59 | spacing_around_non_conditional_operators: true 60 | spacing_around_conditional_operators: true 61 | space_after_cast: true 62 | single_namespace_per_use: true 63 | simplify_boolean_return: true 64 | scope_indentation: 65 | spaces_per_level: '4' 66 | return_doc_comments: true 67 | require_scope_for_properties: true 68 | require_scope_for_methods: true 69 | require_php_tag_first: true 70 | require_braces_around_control_structures: true 71 | remove_trailing_whitespace: true 72 | remove_php_closing_tag: true 73 | remove_extra_empty_lines: true 74 | psr2_switch_declaration: true 75 | psr2_control_structure_declaration: true 76 | psr2_class_declaration: true 77 | property_assignments: true 78 | properties_in_camelcaps: true 79 | prefer_while_loop_over_for_loop: true 80 | phpunit_assertions: true 81 | php5_style_constructor: true 82 | parameters_in_camelcaps: true 83 | parameter_doc_comments: true 84 | return_doc_comment_if_not_inferrable: true 85 | param_doc_comment_if_not_inferrable: true 86 | overriding_private_members: true 87 | optional_parameters_at_the_end: true 88 | one_class_per_file: true 89 | non_commented_empty_catch_block: true 90 | no_unnecessary_if: true 91 | no_unnecessary_function_call_in_for_loop: true 92 | no_unnecessary_final_modifier: true 93 | no_underscore_prefix_in_properties: true 94 | no_underscore_prefix_in_methods: true 95 | no_trailing_whitespace: true 96 | no_space_inside_cast_operator: true 97 | no_space_before_semicolon: true 98 | no_space_around_object_operator: true 99 | no_goto: true 100 | no_global_keyword: true 101 | no_exit: true 102 | no_empty_statements: true 103 | no_else_if_statements: true 104 | no_duplicate_arguments: true 105 | no_debug_code: true 106 | no_commented_out_code: true 107 | newline_at_end_of_file: true 108 | naming_conventions: 109 | local_variable: '^[a-z][a-zA-Z0-9]*$' 110 | abstract_class_name: ^Abstract|Factory$ 111 | utility_class_name: 'Utils?$' 112 | constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$' 113 | property_name: '^[a-z][a-zA-Z0-9]*$' 114 | method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$' 115 | parameter_name: '^[a-z][a-zA-Z0-9]*$' 116 | interface_name: '^[A-Z][a-zA-Z0-9]*Interface$' 117 | type_name: '^[A-Z][a-zA-Z0-9]*$' 118 | exception_name: '^[A-Z][a-zA-Z0-9]*Exception$' 119 | isser_method_name: '^(?:is|has|should|may|supports|was)' 120 | lowercase_php_keywords: true 121 | more_specific_types_in_doc_comments: true 122 | missing_arguments: true 123 | method_calls_on_non_object: true 124 | line_length: 125 | max_length: '120' 126 | lowercase_basic_constants: true 127 | instanceof_class_exists: true 128 | function_in_camel_caps: true 129 | function_body_start_on_new_line: true 130 | fix_use_statements: 131 | remove_unused: true 132 | preserve_multiple: false 133 | preserve_blanklines: false 134 | order_alphabetically: true 135 | foreach_traversable: true 136 | foreach_usable_as_reference: true 137 | fix_php_opening_tag: true 138 | fix_line_ending: true 139 | fix_identation_4spaces: true 140 | fix_doc_comments: true 141 | ensure_lower_case_builtin_functions: true 142 | encourage_postdec_operator: true 143 | classes_in_camel_caps: true 144 | catch_class_exists: true 145 | blank_line_after_namespace_declaration: true 146 | avoid_usage_of_logical_operators: true 147 | avoid_unnecessary_concatenation: true 148 | avoid_tab_indentation: true 149 | avoid_superglobals: true 150 | avoid_perl_style_comments: true 151 | avoid_multiple_statements_on_same_line: true 152 | avoid_fixme_comments: true 153 | avoid_length_functions_in_loops: true 154 | avoid_entity_manager_injection: true 155 | avoid_duplicate_types: true 156 | avoid_corrupting_byteorder_marks: true 157 | argument_type_checks: true 158 | avoid_aliased_php_functions: true 159 | deadlock_detection_in_loops: true 160 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 7.1 5 | - 7.2.5 6 | - 7.3 7 | - 7.4 8 | - 8.0 9 | - nightly 10 | 11 | matrix: 12 | allow_failures: 13 | - php: 7.1 14 | - php: 8.0 15 | - php: nightly 16 | 17 | sudo: false 18 | sudo: false 19 | 20 | install: travis_retry composer install --no-interaction --prefer-dist 21 | 22 | script: vendor/bin/phpunit --verbose 23 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All Notable changes to `Backpack LangFileManager` will be documented in this file 4 | 5 | --- 6 | IMPORTANT 7 | --- 8 | 9 | The changelog is now kept inside the repo's Releases tab, on Github. Please check https://github.com/Laravel-Backpack/LangFileManager/releases for all changes after 3.0.0. 10 | 11 | --- 12 | 13 | ## [3.0.0] - 2020-05-06 14 | 15 | ### Added 16 | - Support for Backpack 4.1; 17 | 18 | ### Removed 19 | - Support for Backpack 4.0; 20 | 21 | 22 | ## [2.0.2] - 2020-01-15 23 | 24 | ### Added 25 | - Persian (farsi) translation; 26 | - Indonesian translation; 27 | 28 | 29 | ## [2.0.1] - 2019-10-19 30 | 31 | ### Added 32 | - German translation; 33 | 34 | 35 | ## [2.0.0] - 2019-10-04 36 | 37 | ### Added 38 | - support for Backpack v4.0; 39 | 40 | ### Removed 41 | - support for Backpack v3.x; 42 | 43 | 44 | ## [1.0.26] - 2019-05-08 45 | 46 | ### Fixed 47 | - using ```backpack_auth()``` instead of ```Auth```; 48 | - bumped required backpack/crud version to 3.5; 49 | 50 | 51 | ## [1.0.25] - 2018-03-13 52 | 53 | ### Fixed 54 | - fixed seeds namespace; 55 | 56 | 57 | ## [1.0.24] - 2018-03-13 58 | 59 | ### Added 60 | - Laravel 5.5 support; 61 | - extend routes functionality; 62 | - spanish translation; 63 | 64 | 65 | ## [1.0.23] - 2018-02-08 66 | 67 | ### Removed 68 | - laravelcollective/html dependency; 69 | 70 | 71 | ## [1.0.22] - 2018-01-09 72 | 73 | ### Added 74 | - Arabic translation (thanks to [AbdelRahman Wahdan](https://github.com/abdelrahmanahmed)); 75 | - original_name for translation fileList; 76 | 77 | ### Fixed 78 | - Language CRUD works with latest Backpack\CRUD version (3.3); 79 | - is_dir() on getlangFiles() to prevent error on no lang directories found; 80 | 81 | 82 | ## [1.0.21] - 2017-08-30 83 | 84 | ### Fixed 85 | - disabled languages were still accessible; 86 | 87 | 88 | ## [1.0.20] - 2017-08-30 89 | 90 | ### Added 91 | - Portugese (pt) language files, thanks to [Toni Almeida](https://github.com/promatik); 92 | - Laravel 5.5 package auto-discovery support; 93 | 94 | 95 | ## [1.0.19] - 2017-08-11 96 | 97 | ### Added 98 | - Brasilian Portugese (pt_BR) language files, thanks to [Guilherme Augusto Henschel](https://github.com/cenoura); 99 | 100 | 101 | ## [1.0.18] - 2016-09-24 102 | 103 | ### Fixed 104 | - Routes now follow base prefix - thanks to [Twaambo Haamucenje](https://github.com/twoSeats); 105 | 106 | 107 | ## [1.0.17] - 2016-09-21 108 | 109 | ### Fixed 110 | - Translation texts can hold HTML. 111 | 112 | 113 | ## [1.0.16] - 2016-08-03 114 | 115 | ### Fixed 116 | - Small english text change. 117 | 118 | 119 | ## [1.0.15] - 2016-07-31 120 | 121 | ### Fixed 122 | - Working bogus unit tests. 123 | 124 | 125 | ## [1.0.13] - 2016-07-12 126 | ### Added by [Federico Liva](http://www.federicoliva.info) 127 | - Sort file list alphabetically for better readability 128 | 129 | 130 | ## [1.0.12] - 2016-07-03 131 | 132 | ### Fixed by [Federico Liva](http://www.federicoliva.info) 133 | - Native language can also be translated now. 134 | - Clone default language folder on new language. 135 | - Config values were ignored. 136 | 137 | 138 | ## [1.0.11] - 2016-06-13 139 | 140 | ### Added by [Federico Liva](http://www.federicoliva.info) 141 | - Add translations and italian localization 142 | 143 | 144 | ## [1.0.10] - 2016-06-07 145 | 146 | ### Added 147 | - Using Backpack\CRUD v2 (with new API); 148 | - Bogus unit test; 149 | 150 | ### Added 151 | - Code style issues; 152 | - Namespace error; 153 | 154 | 155 | ## [1.0.8] - 2016-03-16 156 | 157 | ### Fixed 158 | - Added page title. 159 | 160 | 161 | ## [1.0.7] - 2016-03-12 162 | 163 | ### Fixed 164 | - LangFileManager can no longer use package lang files for backup, because that broke all other packages' backup lang files. Lang files for this package need to be published. 165 | 166 | ## [1.0.6] - 2016-03-12 167 | 168 | ### Fixed 169 | - Lang files are pushed in the correct folder now. For realsies. 170 | - Backpack\CRUD is now a composer requirement. 171 | 172 | 173 | ## [1.0.5] - 2016-03-12 174 | 175 | ### Fixed 176 | - Change folder structure to resemble a Laravel app and other Backpack packages. 177 | - Added the empty_file translation key in langfilemanager's language file. 178 | 179 | 180 | ## [1.0.4] - 2016-03-12 181 | 182 | ### Fixed 183 | - Using a separate lang file from other Backpack packages, which can be published. 184 | 185 | 186 | ## [1.0.3] - 2016-03-12 187 | 188 | ### Fixed 189 | - Renamed from Dick\TranslationManager to Backpack\TranslationManager. 190 | - Now using separate config file. 191 | 192 | 193 | ## [1.0.2] - 2015-09-10 194 | 195 | ### Added 196 | - Migrations and seeds for Laravel-Localizable integration. 197 | - Extra methods on the Language model. 198 | 199 | ## [1.0.0] - 2015-09-07 200 | 201 | ### Added 202 | - Base functionality (edit language files). 203 | - Improved UX over the old interface. 204 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/laravel-backpack/langfilemanager). 6 | 7 | 8 | ## Bug Fixing & Enhancements 9 | 10 | We use the Github issue tracker for that. Here's the procedure we've settled upon so 2 people don't work on the same thing: 11 | - you find something that needs doing (say: unit tests for a certain package); 12 | - you check if there is already an issue for it (if there isn't, add one); 13 | - in that issue: 14 | - say you're working on it and it will be done in x hours or y days; 15 | - in that issue, assign the "working on it" label 16 | - assign yourself to the issue; 17 | - then comment/reference the issue in your pull request; 18 | 19 | 20 | ## Pull Requests 21 | 22 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). It's ok to push non-PSR-2 code, but know that [StyleCI](https://styleci.io/) will convert it after the merge. 23 | 24 | - **Document any change in behaviour** - Make sure the `README.md` is still up-to-date with your modifs. 25 | 26 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 27 | 28 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 29 | 30 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 31 | 32 | 33 | 34 | 35 | ## Running Tests 36 | 37 | The project does NOT have working tests right now, but it really should. If you want to help out, that's one of the most important things you can help with. 38 | 39 | ``` bash 40 | $ composer test 41 | ``` 42 | 43 | 44 | **Happy coding**! 45 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Alin Ghitu 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Backpack LangFileManager 2 | 3 | > ### **Deprecation note** 4 | > 5 | > Backpack team has just released a new package: [Translation Manager](https://github.com/Laravel-Backpack/translation-manager). 6 | This new package uses [Spatie Translation Loader](https://github.com/spatie/laravel-translation-loader) and it works in a more predictable way using the database to store translations. 7 | > 8 | > We **highly** recommend you to switch to [Translation Manager](https://github.com/Laravel-Backpack/translation-manager). 9 | 10 | --- 11 | 12 | [![Latest Version on Packagist][ico-version]][link-packagist] 13 | [![Software License][ico-license]](LICENSE.md) 14 | [![Build Status](https://img.shields.io/travis/Laravel-Backpack/langfilemanager/master.svg?style=flat-square)](https://travis-ci.org/Laravel-Backpack/langfilemanager) 15 | [![Coverage Status][ico-scrutinizer]][link-scrutinizer] 16 | [![Quality Score][ico-code-quality]][link-code-quality] 17 | [![Style CI](https://styleci.io/repos/53691643/shield)](https://styleci.io/repos/53691643) 18 | [![Total Downloads][ico-downloads]][link-downloads] 19 | 20 | A quick interface to edit language files, for Laravel Backpack. 21 | 22 | _**Note:** this interface allows the admin to directly edit the language files stored in ```resources/lang```. Which might not be a great idea in production, if you have those files commited to git and/or use auto-deployment._ 23 | 24 | > ### Security updates and breaking changes 25 | > Please **[subscribe to the Backpack Newsletter](http://backpackforlaravel.com/newsletter)** so you can find out about any security updates, breaking changes or major features. We send an email every 1-2 months. 26 | 27 | 28 | ## Install in Backpack v6.x 29 | 30 | ### Step 1. Install via Composer 31 | 32 | ``` bash 33 | composer require backpack/langfilemanager 34 | ``` 35 | 36 | ### Step 2. Run the migration, seed and file publishing 37 | 38 | ``` bash 39 | php artisan vendor:publish --provider="Backpack\LangFileManager\LangFileManagerServiceProvider" --tag="migrations" #publish the migration file 40 | php artisan migrate 41 | php artisan db:seed --class="Backpack\LangFileManager\database\seeds\LanguageTableSeeder" 42 | php artisan vendor:publish --provider="Backpack\LangFileManager\LangFileManagerServiceProvider" --tag="config" #publish the config file 43 | php artisan vendor:publish --provider="Backpack\LangFileManager\LangFileManagerServiceProvider" --tag="lang" #publish the lang files 44 | ``` 45 | 46 | ### Step 3. Add menu items for it 47 | 48 | Add a menu item for it in resources/views/vendor/backpack/ui/inc/menu_items.blade.php: 49 | 50 | ```html 51 | 52 | 53 | 54 | 55 | ``` 56 | 57 | ## Upgrading from 4.x to 5.x 58 | 59 | You should have no problems upgrading, there have been no breaking changes. Just require the new version. 60 | 61 | ## Upgrading from 3.x to 4.x 62 | 63 | - Flags are no longer supported on the Language CRUD, until version 3 admins could browse an image for the language flag, we now recommend developers to setup those images in advance, having them in a public folder like `public\flags\en.svg` `public\flags\ro.svg`. 64 | 65 | 66 | ## Usage 67 | 68 | Tell LangFileManager what langfiles NOT to show, in config/backpack/langfilemanager.php: 69 | 70 | ``` php 71 | // Language files to NOT show in the LangFileManager 72 | // 73 | 'language_ignore' => ['admin', 'pagination', 'reminders', 'validation', 'log', 'crud'], 74 | ``` 75 | 76 | Or just try at **your-project-domain/admin/language/texts** 77 | 78 | ## Screenshots 79 | 80 | See https://backpackforlaravel.com/ 81 | 82 | ## Change log 83 | 84 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 85 | 86 | 87 | ## Contributing 88 | 89 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 90 | 91 | 92 | ## Security 93 | 94 | If you discover any security related issues, please email tabacitu@backpackforlaravel.com instead of using the issue tracker. 95 | 96 | Please **[subscribe to the Backpack Newsletter](http://backpackforlaravel.com/newsletter)** so you can find out about any security updates, breaking changes or major features. We send an email every 1-2 months. 97 | 98 | ## Credits 99 | 100 | - [Alin Ghitu][link-author] - author 101 | - [Cristian Tabacitu][link-author-2] - contributor 102 | - [All Contributors][link-contributors] 103 | 104 | 105 | ## License 106 | 107 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 108 | 109 | ## Hire us 110 | 111 | We've spend more than 10.000 hours creating, polishing and maintaining administration panels on Laravel. We've developed e-Commerce, e-Learning, ERPs, social networks, payment gateways and much more. We've worked on admin panels _so much_, that we've created one of the most popular software in its niche - just from making public what was repetitive in our projects. 112 | 113 | If you are looking for a developer/team to help you build an admin panel on Laravel, look no further. You'll have a difficult time finding someone with more experience & enthusiasm for this. This is _what we do_. [Contact us - let's see if we can work together](https://backpackforlaravel.com/need-freelancer-or-development-team). 114 | 115 | 116 | [ico-version]: https://img.shields.io/packagist/v/backpack/langfilemanager.svg?style=flat-square 117 | [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square 118 | [ico-travis]: https://img.shields.io/travis/laravel-backpack/langfilemanager/master.svg?style=flat-square 119 | [ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/laravel-backpack/langfilemanager.svg?style=flat-square 120 | [ico-code-quality]: https://img.shields.io/scrutinizer/g/laravel-backpack/langfilemanager.svg?style=flat-square 121 | [ico-downloads]: https://img.shields.io/packagist/dt/backpack/langfilemanager.svg?style=flat-square 122 | 123 | [link-packagist]: https://packagist.org/packages/backpack/langfilemanager 124 | [link-travis]: https://travis-ci.org/laravel-backpack/langfilemanager 125 | [link-scrutinizer]: https://scrutinizer-ci.com/g/laravel-backpack/langfilemanager/code-structure 126 | [link-code-quality]: https://scrutinizer-ci.com/g/laravel-backpack/langfilemanager 127 | [link-downloads]: https://packagist.org/packages/backpack/langfilemanager 128 | [link-author]: https://github.com/ghitu 129 | [link-author-2]: http://tabacitu.ro 130 | [link-contributors]: ../../contributors 131 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backpack/langfilemanager", 3 | "description": "An interface to edit language files, for Laravel Backpack.", 4 | "keywords": [ 5 | "backpack", 6 | "laravel backpack", 7 | "lang files", 8 | "lang file manager", 9 | "language", 10 | "tabacitu", 11 | "laravel", 12 | "admin panel", 13 | "translationmanager" 14 | ], 15 | "homepage": "https://github.com/laravel-backpack/langfilemanager", 16 | "license": "MIT", 17 | "authors": [ 18 | { 19 | "name": "Alin Ghitu", 20 | "email": "alin@updivision.com", 21 | "role": "Lead Developer" 22 | }, 23 | { 24 | "name": "Cristian Tabacitu", 25 | "email": "tabacitu@backpackforlaravel.com", 26 | "homepage": "https://backpackforlaravel.com", 27 | "role": "Contributor & Maintainer" 28 | } 29 | ], 30 | "require": { 31 | "backpack/crud": "^6.0" 32 | }, 33 | "require-dev": { 34 | "phpunit/phpunit" : "^9.0", 35 | "scrutinizer/ocular": "~1.1" 36 | }, 37 | "autoload": { 38 | "psr-4": { 39 | "Backpack\\LangFileManager\\": "src" 40 | } 41 | }, 42 | "autoload-dev": { 43 | "psr-4": { 44 | "Backpack\\LangFileManager\\Test\\": "tests" 45 | } 46 | }, 47 | "scripts": { 48 | "test": "phpunit" 49 | }, 50 | "extra": { 51 | "branch-alias": { 52 | "dev-master": "1.0-dev" 53 | }, 54 | "laravel": { 55 | "providers": [ 56 | "Backpack\\LangFileManager\\LangFileManagerServiceProvider" 57 | ] 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./tests/ 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/LangFileManagerServiceProvider.php: -------------------------------------------------------------------------------- 1 | loadViewsFrom(resource_path('views/vendor/backpack/langfilemanager'), 'langfilemanager'); 36 | // - then the stock views that come with the package, in case a published view might be missing 37 | $this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'langfilemanager'); 38 | 39 | // $this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack'); 40 | 41 | // publish config file 42 | $this->publishes([__DIR__.'/config/backpack/langfilemanager.php' => config_path('backpack/langfilemanager.php')], 'config'); 43 | // publish views 44 | $this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/langfilemanager')], 'views'); 45 | // publish lang files 46 | $this->publishes([__DIR__.'/resources/lang' => $langPath], 'lang'); 47 | 48 | // publish the migrations and seeds 49 | $this->publishes([__DIR__.'/database/migrations/' => database_path('migrations')], 'migrations'); 50 | 51 | // use the vendor configuration file as fallback 52 | $this->mergeConfigFrom(__DIR__.'/config/backpack/langfilemanager.php', 'backpack.langfilemanager'); 53 | } 54 | 55 | /** 56 | * Define the routes for the application. 57 | * 58 | * @param \Illuminate\Routing\Router $router 59 | * @return void 60 | */ 61 | public function setupRoutes(Router $router) 62 | { 63 | // by default, use the routes file provided in vendor 64 | $routeFilePathInUse = __DIR__.$this->routeFilePath; 65 | // but if there's a file with the same name in routes/backpack, use that one 66 | if (file_exists(base_path().$this->routeFilePath)) { 67 | $routeFilePathInUse = base_path().$this->routeFilePath; 68 | } 69 | $this->loadRoutesFrom($routeFilePathInUse); 70 | } 71 | 72 | /** 73 | * Register any package services. 74 | * 75 | * @return void 76 | */ 77 | public function register() 78 | { 79 | $this->registerLangFileManager(); 80 | $this->setupRoutes($this->app->router); 81 | 82 | $this->app->singleton('langfile', function ($app) { 83 | return new LangFiles($app['config']['app']['locale']); 84 | }); 85 | 86 | // use this if your package has a config file 87 | // config([ 88 | // 'config/langfilemanager.php', 89 | // ]); 90 | } 91 | 92 | private function registerLangFileManager() 93 | { 94 | $this->app->bind('langfilemanager', function ($app) { 95 | return new LangFileManager($app); 96 | }); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/app/Http/Controllers/LanguageCrudController.php: -------------------------------------------------------------------------------- 1 | crud->setModel("Backpack\LangFileManager\app\Models\Language"); 22 | $this->crud->setRoute(config('backpack.base.route_prefix', 'admin').'/language'); 23 | $this->crud->setEntityNameStrings(trans('backpack::langfilemanager.language'), trans('backpack::langfilemanager.languages')); 24 | } 25 | 26 | public function setupListOperation() 27 | { 28 | $this->crud->setColumns([ 29 | [ 30 | 'name' => 'name', 31 | 'label' => trans('backpack::langfilemanager.language_name'), 32 | ], 33 | [ 34 | 'name' => 'active', 35 | 'label' => trans('backpack::langfilemanager.active'), 36 | 'type' => 'boolean', 37 | ], 38 | [ 39 | 'name' => 'default', 40 | 'label' => trans('backpack::langfilemanager.default'), 41 | 'type' => 'boolean', 42 | ], 43 | ]); 44 | $this->crud->addButton('line', 'translate', 'view', 'langfilemanager::button', 'beginning'); 45 | } 46 | 47 | public function setupCreateOperation() 48 | { 49 | $this->crud->setValidation(LanguageRequest::class); 50 | $this->crud->addField([ 51 | 'name' => 'name', 52 | 'label' => trans('backpack::langfilemanager.language_name'), 53 | 'type' => 'text', 54 | ]); 55 | $this->crud->addField([ 56 | 'name' => 'native', 57 | 'label' => trans('backpack::langfilemanager.native_name'), 58 | 'type' => 'text', 59 | ]); 60 | $this->crud->addField([ 61 | 'name' => 'abbr', 62 | 'label' => trans('backpack::langfilemanager.code_iso639-1'), 63 | 'type' => 'text', 64 | ]); 65 | $this->crud->addField([ 66 | 'name' => 'flag', 67 | 'label' => trans('backpack::langfilemanager.flag_image'), 68 | 'type' => backpack_pro() ? 'browse' : 'text', 69 | ]); 70 | $this->crud->addField([ 71 | 'name' => 'active', 72 | 'label' => trans('backpack::langfilemanager.active'), 73 | 'type' => 'checkbox', 74 | ]); 75 | $this->crud->addField([ 76 | 'name' => 'default', 77 | 'label' => trans('backpack::langfilemanager.default'), 78 | 'type' => 'checkbox', 79 | ]); 80 | } 81 | 82 | public function setupUpdateOperation() 83 | { 84 | return $this->setupCreateOperation(); 85 | } 86 | 87 | public function store() 88 | { 89 | $defaultLang = Language::where('default', 1)->first(); 90 | 91 | // Copy the default language folder to the new language folder 92 | \File::copyDirectory(resource_path('lang/'.$defaultLang->abbr), resource_path('lang/'.request()->input('abbr'))); 93 | 94 | return $this->traitStore(); 95 | } 96 | 97 | /** 98 | * After delete remove also the language folder. 99 | * 100 | * @param int $id 101 | * @return string 102 | */ 103 | public function destroy($id) 104 | { 105 | $language = Language::find($id); 106 | $destroyResult = $this->traitDestroy($id); 107 | 108 | if ($destroyResult) { 109 | \File::deleteDirectory(resource_path('lang/'.$language->abbr)); 110 | } 111 | 112 | return $destroyResult; 113 | } 114 | 115 | public function showTexts(LangFiles $langfile, Language $languages, $lang = '', $file = 'site') 116 | { 117 | // SECURITY 118 | // check if that file isn't forbidden in the config file 119 | if (in_array($file, config('backpack.langfilemanager.language_ignore'))) { 120 | abort('403', trans('backpack::langfilemanager.cant_edit_online')); 121 | } 122 | 123 | if ($lang) { 124 | $langfile->setLanguage($lang); 125 | } 126 | 127 | $langfile->setFile($file); 128 | $this->data['crud'] = $this->crud; 129 | $this->data['currentFile'] = $file; 130 | $this->data['currentLang'] = $lang ?: config('app.locale'); 131 | $this->data['currentLangObj'] = Language::where('abbr', '=', $this->data['currentLang'])->first(); 132 | $this->data['browsingLangObj'] = Language::where('abbr', '=', config('app.locale'))->first(); 133 | $this->data['languages'] = $languages->orderBy('name')->where('active', 1)->get(); 134 | $this->data['langFiles'] = $langfile->getlangFiles(); 135 | $this->data['fileArray'] = $langfile->getFileContent(); 136 | $this->data['langfile'] = $langfile; 137 | $this->data['title'] = trans('backpack::langfilemanager.translations'); 138 | 139 | return view('langfilemanager::translations', $this->data); 140 | } 141 | 142 | public function updateTexts(LangFiles $langfile, Request $request, $lang = '', $file = 'site') 143 | { 144 | // SECURITY 145 | // check if that file isn't forbidden in the config file 146 | if (in_array($file, config('backpack.langfilemanager.language_ignore'))) { 147 | abort('403', trans('backpack::langfilemanager.cant_edit_online')); 148 | } 149 | 150 | $message = trans('error.error_general'); 151 | $status = false; 152 | 153 | if ($lang) { 154 | $langfile->setLanguage($lang); 155 | } 156 | 157 | $langfile->setFile($file); 158 | 159 | $fields = $langfile->testFields($request->all()); 160 | if (empty($fields)) { 161 | if ($langfile->setFileContent($request->all())) { 162 | \Alert::success(trans('backpack::langfilemanager.saved'))->flash(); 163 | $status = true; 164 | } 165 | } else { 166 | $message = trans('admin.language.fields_required'); 167 | \Alert::error(trans('backpack::langfilemanager.please_fill_all_fields'))->flash(); 168 | } 169 | 170 | return redirect()->back(); 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/app/Http/Requests/LanguageRequest.php: -------------------------------------------------------------------------------- 1 | check(); 18 | } 19 | 20 | /** 21 | * Get the validation rules that apply to the request. 22 | * 23 | * @return array 24 | */ 25 | public function rules() 26 | { 27 | return [ 28 | 'name' => 'required|min:3|max:255', 29 | 'abbr' => 'required|min:2|max:2', 30 | ]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/app/Models/Language.php: -------------------------------------------------------------------------------- 1 | get()->toArray(); 21 | $localizable_languages_array = []; 22 | 23 | if (count($active_languages)) { 24 | foreach ($active_languages as $key => $lang) { 25 | $localizable_languages_array[$lang['abbr']] = $lang; 26 | } 27 | 28 | return $localizable_languages_array; 29 | } 30 | 31 | return config('laravellocalization.supportedLocales'); 32 | } 33 | 34 | public static function findByAbbr($abbr = false) 35 | { 36 | return self::where('abbr', $abbr)->first(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/app/Services/LangFiles.php: -------------------------------------------------------------------------------- 1 | lang = config('app.locale'); 14 | } 15 | 16 | public function setLanguage($lang) 17 | { 18 | $this->lang = $lang; 19 | 20 | return $this; 21 | } 22 | 23 | public function setFile($file) 24 | { 25 | $this->file = $file; 26 | 27 | return $this; 28 | } 29 | 30 | /** 31 | * Get the content of a language file as an array sorted ascending. 32 | * 33 | * @return array|false 34 | */ 35 | public function getFileContent() 36 | { 37 | $filepath = $this->getFilePath(); 38 | 39 | if (is_file($filepath)) { 40 | $wordsArray = include $filepath; 41 | asort($wordsArray); 42 | 43 | return $wordsArray; 44 | } 45 | 46 | return false; 47 | } 48 | 49 | /** 50 | * Rewrite the file with the modified texts. 51 | * 52 | * @param array $postArray the data received from the form 53 | * @return int 54 | */ 55 | public function setFileContent($postArray) 56 | { 57 | $postArray = $this->prepareContent($postArray); 58 | 59 | $return = (int) file_put_contents( 60 | $this->getFilePath(), 61 | print_r("var_export54($postArray).";\n", true) 62 | ); 63 | 64 | return $return; 65 | } 66 | 67 | /** 68 | * Get the language files that can be edited, 69 | * to ignore a file add it in the config/admin file to language_ignore key. 70 | * 71 | * @return array 72 | */ 73 | public function getlangFiles() 74 | { 75 | $fileList = []; 76 | 77 | foreach (is_dir($this->getLangPath()) ? scandir($this->getLangPath(), SCANDIR_SORT_DESCENDING) : [] as $file) { 78 | $fileName = str_replace('.php', '', $file); 79 | 80 | if (! in_array($fileName, array_merge(['.', '..'], config('backpack.langfilemanager.language_ignore')))) { 81 | $fileList[] = [ 82 | 'name' => ucfirst(str_replace('_', ' ', $fileName)), 83 | 'original_name' => $fileName, 84 | 'url' => url(config('backpack.base.route_prefix', 'admin')."/language/texts/{$this->lang}/{$fileName}"), 85 | 'active' => $fileName == $this->file, 86 | ]; 87 | } 88 | } 89 | 90 | // Sort files by name for better readability 91 | usort($fileList, function ($a, $b) { 92 | return strnatcmp($a['name'], $b['name']); 93 | }); 94 | 95 | return $fileList; 96 | } 97 | 98 | /** 99 | * Check if all the fields were completed. 100 | * 101 | * @param array $postArray the array containing the data 102 | * @return array 103 | */ 104 | public function testFields($postArray) 105 | { 106 | $returnArray = []; 107 | 108 | foreach ($postArray as $key => $value) { 109 | if (is_array($value)) { 110 | foreach ($value as $k => $item) { 111 | foreach ($item as $j => $it) { 112 | if (trim($it) == '') { 113 | $returnArray[] = ['parent' => $key, 'child' => $j]; 114 | } 115 | } 116 | } 117 | } else { 118 | if (trim($value) == '') { 119 | $returnArray[] = $key; 120 | } 121 | } 122 | } 123 | 124 | return $returnArray; 125 | } 126 | 127 | /** 128 | * Display the form that permits the editing. 129 | * 130 | * @param array $fileArray the array with all the texts 131 | * @param array $parents all the ancestor keys of the current key 132 | * @param string $parent the parent key of the current key 133 | * @param int $level the current level 134 | * @return void 135 | */ 136 | public function displayInputs($fileArray, $parents = [], $parent = '', $level = 0) 137 | { 138 | $level++; 139 | if ($parent) { 140 | $parents[] = $parent; 141 | } 142 | foreach ($fileArray as $key => $item) { 143 | if (is_array($item)) { 144 | echo view()->make('langfilemanager::language_headers', [ 145 | 'header' => $key, 146 | 'parents' => $parents, 147 | 'level' => $level, 148 | 'item' => $item, 149 | 'langfile' => $this, 150 | 'lang_file_name' => $this->file, 151 | ])->render(); 152 | } else { 153 | echo view()->make('langfilemanager::language_inputs', [ 154 | 'key' => $key, 155 | 'item' => $item, 156 | 'parents' => $parents, 157 | 'lang_file_name' => $this->file, 158 | ])->render(); 159 | } 160 | } 161 | } 162 | 163 | /** 164 | * Create the array that will be saved in the file. 165 | * 166 | * @param array $postArray The array to be transformed 167 | * @return array 168 | */ 169 | private function prepareContent($postArray) 170 | { 171 | $returnArray = []; 172 | 173 | unset($postArray['_token']); 174 | 175 | foreach ($postArray as $key => $item) { 176 | $keys = explode('__', $key); 177 | 178 | if (is_array($item)) { 179 | if (isset($item['before'])) { 180 | $items_arr = array_map( 181 | function ($item1, $item2) { 182 | return $item1.$item2; 183 | }, 184 | str_replace('|', '|', $item['before']), 185 | str_replace('|', '|', $item['after']) 186 | ); 187 | $value = $this->sanitize(implode('|', $items_arr)); 188 | } else { 189 | $value = $this->sanitize(implode('|', str_replace('|', '|', $item['after']))); 190 | } 191 | } else { 192 | $value = $this->sanitize(str_replace('|', '|', $item)); 193 | } 194 | 195 | $this->setArrayValue($returnArray, $keys, $value); 196 | } 197 | 198 | return $returnArray; 199 | } 200 | 201 | /** 202 | * Add filters to the values inserted by the user. 203 | * 204 | * @param string $str the string to be sanitized 205 | * @return string 206 | */ 207 | private function sanitize($str) 208 | { 209 | return trim($str); 210 | } 211 | 212 | /** 213 | * Set a value in a multidimensional array when knowing the keys. 214 | * 215 | * @param array $data the array that will be modified 216 | * @param array $keys the keys (path) 217 | * @param string $value the value to be added 218 | * @return array 219 | */ 220 | private function setArrayValue(&$data, $keys, $value) 221 | { 222 | foreach ($keys as $key) { 223 | $data = &$data[$key]; 224 | } 225 | 226 | return $data = $value; 227 | } 228 | 229 | private function getFilePath() 230 | { 231 | return $this->getLangPath().'/'.$this->file.'.php'; 232 | } 233 | 234 | private function getLangPath() 235 | { 236 | return app()->langPath().'/'.$this->lang; 237 | } 238 | 239 | private function var_export54($var, $indent = '') 240 | { 241 | switch (gettype($var)) { 242 | case 'string': 243 | return "'".addcslashes($var, "\\\$'\r\n\t\v\f")."'"; 244 | case 'array': 245 | $r = []; 246 | foreach ($var as $key => $value) { 247 | $r[] = "$indent " 248 | .(is_numeric($key) ? '' : $this->var_export54($key).' => ') 249 | .$this->var_export54($value, "$indent "); 250 | } 251 | 252 | return "[\n".implode(",\n", $r).",\n{$indent}]"; 253 | case 'boolean': 254 | return $var ? 'true' : 'false'; 255 | default: 256 | return var_export($var, true); 257 | } 258 | } 259 | } 260 | -------------------------------------------------------------------------------- /src/config/backpack/langfilemanager.php: -------------------------------------------------------------------------------- 1 | ['pagination', 'reminders', 'validation', 'log', 'crud'], 9 | 10 | ]; 11 | -------------------------------------------------------------------------------- /src/database/migrations/2015_09_07_190535_create_languages_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name', 100); 18 | $table->string('flag', 100)->nullable(); 19 | $table->string('abbr', 3); 20 | $table->tinyInteger('active')->unsigned()->default('1'); 21 | $table->tinyInteger('default')->unsigned()->default('0'); 22 | $table->timestamps(); 23 | $table->softDeletes(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::drop('languages'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/database/migrations/2015_09_10_124414_alter_languages_table.php: -------------------------------------------------------------------------------- 1 | string('script', 20)->nullable()->after('abbr'); 16 | $table->string('native', 20)->nullable()->after('script'); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('languages', function ($table) { 28 | $table->dropColumn('script'); 29 | $table->dropColumn('native'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/database/seeds/LanguageTableSeeder.php: -------------------------------------------------------------------------------- 1 | insert([ 18 | 'name' => 'English', 19 | 'flag' => '', 20 | 'abbr' => 'en', 21 | 'script' => 'Latn', 22 | 'native' => 'English', 23 | 'active' => '1', 24 | 'default' => '1', 25 | ]); 26 | 27 | DB::table('languages')->insert([ 28 | 'name' => 'Romanian', 29 | 'flag' => '', 30 | 'abbr' => 'ro', 31 | 'script' => 'Latn', 32 | 'native' => 'română', 33 | 'active' => '1', 34 | 'default' => '0', 35 | ]); 36 | 37 | DB::table('languages')->insert([ 38 | 'name' => 'French', 39 | 'flag' => '', 40 | 'abbr' => 'fr', 41 | 'script' => 'Latn', 42 | 'native' => 'français', 43 | 'active' => '0', 44 | 'default' => '0', 45 | ]); 46 | 47 | DB::table('languages')->insert([ 48 | 'name' => 'Italian', 49 | 'flag' => '', 50 | 'abbr' => 'it', 51 | 'script' => 'Latn', 52 | 'native' => 'italiano', 53 | 'active' => '0', 54 | 'default' => '0', 55 | ]); 56 | 57 | DB::table('languages')->insert([ 58 | 'name' => 'Spanish', 59 | 'flag' => '', 60 | 'abbr' => 'es', 61 | 'script' => 'Latn', 62 | 'native' => 'español', 63 | 'active' => '0', 64 | 'default' => '0', 65 | ]); 66 | 67 | DB::table('languages')->insert([ 68 | 'name' => 'German', 69 | 'flag' => '', 70 | 'abbr' => 'de', 71 | 'script' => 'Latn', 72 | 'native' => 'Deutsch', 73 | 'active' => '0', 74 | 'default' => '0', 75 | ]); 76 | 77 | $this->command->info('Language seeding successful.'); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/resources/lang/ar/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'مفعَّل', 17 | 'cant_edit_online' => 'ملف اللغة هذا ﻻ يمكن التعديل فيه عبر اﻻنترنت', 18 | 'code_iso639-1' => '(ISO 639-1) كود', 19 | 'default' => 'اﻻفتراضي', 20 | 'empty_file' => 'ﻻ يوجد ترجمة متاحة', 21 | 'flag_image' => 'صورة العلم', 22 | 'key' => 'المفتاح', 23 | 'language' => 'لغة', 24 | 'language_name' => 'اسم اللغة', 25 | 'language_text' => ':language_name نص', 26 | 'language_translation' => ':language_name ترجمة', 27 | 'languages' => 'اللغات', 28 | 'please_fill_all_fields' => 'من فضلك إمﻷ كل الحقول', 29 | 'rules_text' => "تنويه: ﻻ تترجم الكلمات اللي تحتوي على خط على سطر (مثال :':number_of_items')، هذه الكلمات سوف تستبدل تلقائيا مع القيمة المناسبة ، إذا ترجمتها ،لن يتم استبدالها بالقيمة المناسبة.", 30 | 'saved' => 'تم الحفظ', 31 | 'site_texts' => 'نصوص الموقع', 32 | 'switch_to' => 'التغيير إلى', 33 | 'texts' => 'النصوص', 34 | 'translate' => 'ترجم', 35 | 'translations' => 'ترجمة', 36 | 'native_name' => 'اﻻسم اﻷصلي', 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /src/resources/lang/de/langsfilemanager.php: -------------------------------------------------------------------------------- 1 | 'Aktiv', 17 | 'cant_edit_online' => 'Diese Sprache kann Online nicht editiert werden.', 18 | 'code_iso639-1' => 'Code (ISO 639-1)', 19 | 'default' => 'Standart', 20 | 'empty_file' => 'Keine Übersetzungen verfügbar.', 21 | 'flag_image' => 'Bild Markieren', 22 | 'key' => 'Key', 23 | 'language' => 'Sprache', 24 | 'language_name' => 'Sprachen Name', 25 | 'language_text' => ':language_name Text', 26 | 'language_translation' => ':language_name Übersetzung', 27 | 'languages' => 'Sprachen', 28 | 'please_fill_all_fields' => 'Bitte alle Felder ausfüllen', 29 | 'rules_text' => "Hinweis: Übersetzen Sie keine Wörter, denen ein Doppelpunkt vorangestellt ist (z.B.: ':number_of_items'). Diese werden automatisch durch einen passenden Wert ersetzt. Falls ersetzt, funktioniert die Übersetzung nicht korrekt.", 30 | 'saved' => 'Gespeichert', 31 | 'site_texts' => 'Seitentexte', 32 | 'switch_to' => 'Wechseln zu', 33 | 'texts' => 'Texte', 34 | 'translate' => 'Übersetzen', 35 | 'translations' => 'Übersetzungen', 36 | 'native_name' => 'Nativer Name', 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /src/resources/lang/en/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'Active', 17 | 'cant_edit_online' => 'This language file cannot be edited online.', 18 | 'code_iso639-1' => 'Code (ISO 639-1)', 19 | 'default' => 'Default', 20 | 'empty_file' => 'No translations available.', 21 | 'flag_image' => 'Flag image', 22 | 'key' => 'Key', 23 | 'language' => 'language', 24 | 'language_name' => 'Language name', 25 | 'language_text' => ':language_name text', 26 | 'language_translation' => ':language_name translation', 27 | 'languages' => 'languages', 28 | 'please_fill_all_fields' => 'Please fill all fields', 29 | 'rules_text' => "Notice: Do not translate words prefixed with colon (ex: ':number_of_items'). Those will be replaced automatically with a proper value. If translated, that stops working.", 30 | 'saved' => 'Saved', 31 | 'site_texts' => 'Site texts', 32 | 'switch_to' => 'Switch to', 33 | 'texts' => 'Texts', 34 | 'translate' => 'Translate', 35 | 'translations' => 'Translations', 36 | 'native_name' => 'Native name', 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /src/resources/lang/es/langfilemanager.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laravel-Backpack/LangFileManager/8551174cb37bc0e97af6a8db784263b0dcaf72fe/src/resources/lang/es/langfilemanager.php -------------------------------------------------------------------------------- /src/resources/lang/fa/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'فعال', 17 | 'cant_edit_online' => 'این پرونده زبان به صورت آنلاین قابل ویرایش نیست.', 18 | 'code_iso639-1' => 'کد (ISO 639-1)', 19 | 'default' => 'پیشفرض', 20 | 'empty_file' => 'ترجمه‌ای موجود نیست.', 21 | 'flag_image' => 'تصویر پرچم', 22 | 'key' => 'کلید', 23 | 'language' => 'ربان', 24 | 'language_name' => 'نام بان', 25 | 'language_text' => 'متن :language_name', 26 | 'language_translation' => 'ترجمه :language_name', 27 | 'languages' => 'زبان‌ها', 28 | 'please_fill_all_fields' => 'لطفا همه فیلد‌ها را پر کنید.', 29 | 'rules_text' => "اطلاعیه: کلمات شروع شونده با دونقطه را ترجمه نکنید (مثال: ': number_of_items'). آنها با یک مقدار مناسب جایگزین می شوند. اگر ترجمه شود ، این کار متوقف می‌شود.", 30 | 'saved' => 'ذخیره شد', 31 | 'site_texts' => 'متن‌های سایت', 32 | 'switch_to' => 'تغییر به', 33 | 'texts' => 'متن‌ها', 34 | 'translate' => 'ترجمه', 35 | 'translations' => 'ترجمه‌ها', 36 | 'native_name' => 'نام بومی', 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /src/resources/lang/id/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'Aktif', 17 | 'cant_edit_online' => 'File bahasa ini tidak dapat diedit online.', 18 | 'code_iso639-1' => 'Kode (ISO 639-1)', 19 | 'default' => 'Default', 20 | 'empty_file' => 'Tidak ada terjemahan yang tersedia.', 21 | 'flag_image' => 'Gambar bendera', 22 | 'key' => 'Kunci', 23 | 'language' => 'bahasa', 24 | 'language_name' => 'Nama Bahasa', 25 | 'language_text' => ':language_name teks', 26 | 'language_translation' => ':language_name terjemahan', 27 | 'languages' => 'bahasa', 28 | 'please_fill_all_fields' => 'Silakan isi semua kolom', 29 | 'rules_text' => 'Peringatan: Jangan menerjemahkan kata yang diawali dengan titik dua (cth: ":number_of_items"). Itu akan diganti secara otomatis dengan nilai yang tepat. Jika diterjemahkan, akan berhenti berfungsi.', 30 | 'saved' => 'Tersimpan', 31 | 'site_texts' => 'Teks situs', 32 | 'switch_to' => 'Beralih ke', 33 | 'texts' => 'Teks', 34 | 'translate' => 'Terjemahkan', 35 | 'translations' => 'Terjemahan', 36 | 'native_name' => 'Nama asli', 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /src/resources/lang/it/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'Attivo', 17 | 'cant_edit_online' => 'Questa lingua non può essere modificata online.', 18 | 'code_iso639-1' => 'Codice (ISO 639-1)', 19 | 'default' => 'Predefinito', 20 | 'empty_file' => 'Nessuna traduzione disponibile.', 21 | 'flag_image' => 'Immagine bandiera', 22 | 'key' => 'Chiave', 23 | 'language' => 'lingua', 24 | 'language_name' => 'Nome lingua', 25 | 'language_text' => 'Testo :language_name', 26 | 'language_translation' => 'Traduzione :language_name', 27 | 'languages' => 'lingue', 28 | 'please_fill_all_fields' => 'Compila tutto i campi', 29 | 'rules_text' => "Avviso: Non tradurre le parole che iniziano con due punti (es: ':number_of_items'). Queste verranno sostituite automaticamente con un valore adeguato. Se tradotte, smetteranno di funzionare.", 30 | 'saved' => 'Salvato', 31 | 'site_texts' => 'Testi del sito', 32 | 'switch_to' => 'Passa a', 33 | 'texts' => 'testi', 34 | 'translate' => 'Traduci', 35 | 'translations' => 'Traduzioni', 36 | 'native_name' => 'Nome nativo', 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /src/resources/lang/pt/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'Ativo', 17 | 'cant_edit_online' => 'Este ficheiro não pode ser editado online.', 18 | 'code_iso639-1' => 'Código (ISO 639-1)', 19 | 'default' => 'Predefinido', 20 | 'empty_file' => 'Sem traduções disponíveis.', 21 | 'flag_image' => 'Bandeira', 22 | 'key' => 'Chave', 23 | 'language' => 'idioma', 24 | 'language_name' => 'Nome do idioma', 25 | 'language_text' => 'Texto em :language_name', 26 | 'language_translation' => 'Tradução em :language_name', 27 | 'languages' => 'idiomas', 28 | 'please_fill_all_fields' => 'Por favor preencha todos os campos', 29 | 'rules_text' => "Aviso: Não devem ser traduzidas expressões antecedidas com dois pontos ':' (ex: ':number_of_items'). Essas palavras serão substituídas automaticamente com o valor correto.", 30 | 'saved' => 'Guardado', 31 | 'site_texts' => 'Textos do site', 32 | 'switch_to' => 'Alterar para', 33 | 'texts' => 'Textos', 34 | 'translate' => 'Traduzir', 35 | 'translations' => 'Traduções', 36 | 'native_name' => 'Nome nativo', 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /src/resources/lang/pt_br/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'Ativa', 17 | 'cant_edit_online' => 'Este arquivo de tradução não pode ser editado online.', 18 | 'code_iso639-1' => 'Código (ISO 639-1)', 19 | 'default' => 'Padrão', 20 | 'empty_file' => 'Nenhuma tradução disponível.', 21 | 'flag_image' => 'Imagem da bandeira', 22 | 'key' => 'Chave', 23 | 'language' => 'idioma', 24 | 'language_name' => 'Nome do Idioma', 25 | 'language_text' => 'texto de :language_name', 26 | 'language_translation' => 'tradução de :language_name', 27 | 'languages' => 'idiomas', 28 | 'please_fill_all_fields' => 'Por favor, preencha todos os campos', 29 | 'rules_text' => "Aviso: Não traduza palavras prefixadas com dois pontos (ex: ':number_of_items'). Elas serão substituídas automaticamente pelo seu respectivo valor. Se traduzidas, elas não funcionarão.", 30 | 'saved' => 'Salvo', 31 | 'site_texts' => 'Textos do site', 32 | 'switch_to' => 'Trocar para', 33 | 'texts' => 'Textos', 34 | 'translate' => 'Tradução', 35 | 'translations' => 'Traduções', 36 | 'native_name' => 'Nome nativo', 37 | ]; 38 | -------------------------------------------------------------------------------- /src/resources/lang/tr/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'Aktif', 17 | 'cant_edit_online' => 'Bu dosya çevirimiçi olarak düzenlenemez.', 18 | 'code_iso639-1' => 'Kod (ISO 639-1)', 19 | 'default' => 'Varsayılan', 20 | 'empty_file' => 'Şuanda yapılabilecek bir çeviri yok.', 21 | 'flag_image' => 'Bayrak görseli', 22 | 'key' => 'Anahtar', 23 | 'language' => 'dil', 24 | 'language_name' => 'Dil adı', 25 | 'language_text' => ':language_name metin', 26 | 'language_translation' => ':language_name çeviri', 27 | 'languages' => 'diller', 28 | 'please_fill_all_fields' => 'Lütfen tüm boş alanları doldurun.', 29 | 'rules_text' => "Not : Çeviri yaparken (örn: ':number_of_items'). Şeklinde başında üst üste iki nokta olan alanları değiştirmeyiniz.", 30 | 'saved' => 'Kaydet', 31 | 'site_texts' => 'Site metinleri', 32 | 'switch_to' => 'Değiştir', 33 | 'texts' => 'Metinler', 34 | 'translate' => 'Çevir', 35 | 'translations' => 'Çeviriler', 36 | 'native_name' => 'Gerçek Adı', 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /src/resources/lang/vi/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'Hoạt động', 17 | 'cant_edit_online' => 'File ngôn ngữ này không thể chỉnh sửa trực tuyến.', 18 | 'code_iso639-1' => 'Mã (ISO 639-1)', 19 | 'default' => 'Mặc định', 20 | 'empty_file' => 'Không có bản dịch nào.', 21 | 'flag_image' => 'Ảnh cờ', 22 | 'key' => 'Khóa', 23 | 'language' => 'Ngôn ngữ', 24 | 'language_name' => 'Tên ngôn ngữ', 25 | 'language_text' => 'Văn bản :language_name', 26 | 'language_translation' => 'Bản dịch :language_name', 27 | 'languages' => 'Ngôn ngữ', 28 | 'please_fill_all_fields' => 'Vui lòng điền đầy đủ thông tin cho tất cả các trường', 29 | 'rules_text' => "Chú ý: Không dịch các từ có tiền tố là dấu hai chấm (ví dụ: ':number_of_items'). Những từ này sẽ tự động thay thế bằng giá trị thích hợp. Nếu dịch, chúng sẽ không hoạt động.", 30 | 'saved' => 'Đã lưu', 31 | 'site_texts' => 'Văn bản trang web', 32 | 'switch_to' => 'Chuyển sang', 33 | 'texts' => 'Văn bản', 34 | 'translate' => 'Dịch', 35 | 'translations' => 'Bản dịch', 36 | 'native_name' => 'Tên bản địa', 37 | ]; 38 | -------------------------------------------------------------------------------- /src/resources/lang/zh-cn/langfilemanager.php: -------------------------------------------------------------------------------- 1 | '活动', 17 | 'cant_edit_online' => '此语言文件无法在线编辑。', 18 | 'code_iso639-1' => 'ISO语言代码 (ISO 639-1)', 19 | 'default' => '默认', 20 | 'empty_file' => '暂无翻译。', 21 | 'flag_image' => '国旗图片', 22 | 'key' => '键', 23 | 'language' => '语言', 24 | 'language_name' => '语言名称', 25 | 'language_text' => ':language_name 文本', 26 | 'language_translation' => ':language_name 翻译', 27 | 'languages' => '语言', 28 | 'please_fill_all_fields' => '请填写所有字段', 29 | 'rules_text' => "注意: 不要翻译前缀有冒号的单词 (例如: ':number_of_items')。 这些将会被自动替换为适当的值。 如果翻译,将无法使用。", 30 | 'saved' => '已保存', 31 | 'site_texts' => '站点文本', 32 | 'switch_to' => '切换到', 33 | 'texts' => '文本', 34 | 'translate' => '翻译', 35 | 'translations' => '翻译', 36 | 'native_name' => '本地名称', 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /src/resources/views/button.blade.php: -------------------------------------------------------------------------------- 1 | 2 | {{ trans('backpack::langfilemanager.translate') }} -------------------------------------------------------------------------------- /src/resources/views/language_headers.blade.php: -------------------------------------------------------------------------------- 1 |
2 |

3 | {!! /*$level.*/ucfirst(str_replace(['_', '-'], ' ', trim($header))) !!} 4 | 5 |

6 |
7 | {!! $langfile->displayInputs($item, $parents, $header, $level) !!} 8 |
9 |
10 | -------------------------------------------------------------------------------- /src/resources/views/language_inputs.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 16 |
17 | @if (preg_match('/(\|)/', $item)) 18 | @php 19 | $chuncks = explode('|', $item); 20 | @endphp 21 | 22 |
23 | @foreach ($chuncks as $k => $chunck) 24 | @php 25 | preg_match('/^({\w}|\[[\w,]+\])([\w\s:]+)/', trim($chunck), $m); 26 | @endphp 27 | @if (empty($m)) 28 | 29 | 30 |
31 | @else 32 | 33 | 34 | 35 |
36 | @endif 37 | @endforeach 38 |
39 | @else 40 | 41 |
42 | @endif 43 |
44 |
-------------------------------------------------------------------------------- /src/resources/views/translations.blade.php: -------------------------------------------------------------------------------- 1 | @extends(backpack_view('blank')) 2 | 3 | @php 4 | $defaultBreadcrumbs = [ 5 | trans('backpack::crud.admin') => backpack_url('dashboard'), 6 | $crud->entity_name_plural => url($crud->route), 7 | trans('backpack::crud.edit').' '.trans('backpack::langfilemanager.texts') => false, 8 | ]; 9 | 10 | // if breadcrumbs aren't defined in the CrudController, use the default breadcrumbs 11 | $breadcrumbs = $breadcrumbs ?? $defaultBreadcrumbs; 12 | @endphp 13 | 14 | @section('header') 15 |
16 |

17 | {{ trans('backpack::langfilemanager.translate') }} 18 |

19 |

20 | {{ trans('backpack::langfilemanager.site_texts') }}. 21 |

22 | @if ($crud->hasAccess('list')) 23 |

24 | {{ 25 | trans('backpack::crud.back_to_all') }} {{ $crud->entity_name_plural }} 26 |

27 | @endif 28 |
29 | @endsection 30 | 31 | @section('content') 32 | 33 |
34 |
35 |
36 | 37 |   {{ trans('backpack::langfilemanager.switch_to') }}:   38 | 43 | 44 |
45 |
46 |
47 | 54 |
55 | @if (!empty($fileArray)) 56 |
63 | {!! csrf_field() !!} 64 |
65 |
66 |
{{ trans('backpack::langfilemanager.key') }}
67 |
68 | 71 |
72 |
{{ trans('backpack::langfilemanager.language_translation', ['language_name' => $currentLangObj->name]) }}
73 |
74 |
75 | {!! $langfile->displayInputs($fileArray) !!} 76 |
77 |
78 | 79 |
80 |
81 | @else 82 | {{ trans('backpack::langfilemanager.empty_file') }} 83 | @endif 84 |
85 |
86 |

{!! trans('backpack::langfilemanager.rules_text') !!}

87 |
88 | @endsection 89 | 90 | @section('after_scripts') 91 | 98 | @endsection 99 | -------------------------------------------------------------------------------- /src/routes/backpack/langfilemanager.php: -------------------------------------------------------------------------------- 1 | 'Backpack\LangFileManager\app\Http\Controllers', 6 | 'prefix' => config('backpack.base.route_prefix', 'admin'), 7 | 'middleware' => ['web', config('backpack.base.middleware_key', 'admin')], 8 | ], function () { 9 | // Language 10 | Route::get('language/texts/{lang?}/{file?}', 'LanguageCrudController@showTexts'); 11 | Route::post('language/texts/{lang}/{file}', 'LanguageCrudController@updateTexts'); 12 | Route::crud('language', 'LanguageCrudController'); 13 | }); 14 | -------------------------------------------------------------------------------- /tests/LanguageCrudControllerTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 13 | } 14 | } 15 | --------------------------------------------------------------------------------