started to activate translations ajax nav
This commit is contained in:
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,65 @@
|
||||
Translation View
|
||||
=============
|
||||
|
||||
## Description:
|
||||
Provides fields and filter for views to display information about the current row, the **source** translation, in another **target** language. You can also add translation operation links to decide if you want to add/edit the content in the target language.
|
||||
|
||||
Configurations for a demo view is impored on installation, named `Content translation jobs` which can be found at path `/translate/content`. If you want to get view for other translatable entities, you should build it yourself using our fields/filters.
|
||||
|
||||
**Notice**: This module provides view's fields/filters only for translatble entity types, this means that until you have enabled content translation support for an entity you'll not get provided any extra fields/filters. The content translations can be enabled at path `admin/config/regional/content-language`
|
||||
|
||||
## Features
|
||||
|
||||
**Target translation**
|
||||
|
||||
- Target language: `field`,`filter`. Should in most cases be an exposed filter.
|
||||
Also there is an extra filter option: *Remove rows where source language is equal to target language*
|
||||
|
||||
These fields/filters will display information about the current content in the selected target language:
|
||||
- Translation outdated: `field`,`filter`
|
||||
- Translation status: `field`,`filter`
|
||||
- Target language equals default language: `field`,`filter`: Checks if the target language is the same as the original language of the node.
|
||||
- Translation changed time: `field`
|
||||
- Translation source equals row language: `field`,`filter`: Checks if the source translation of the target language is the same as the language of the row
|
||||
- Translation operations: `field`
|
||||
|
||||
**Source translation**
|
||||
- Translation counter: `field`,`filter`
|
||||
|
||||
## Requirements:
|
||||
- Drupal 8
|
||||
- PHP 5.6+
|
||||
|
||||
## Installation:
|
||||
Install module as usually.
|
||||
|
||||
### Demo view: Content translation jobs:
|
||||
Upon installation a new view is added named `Content translation jobs` that demonstrate how the fields/filters can be used to create lists of translation jobs. Available at path `/translate/content`.
|
||||
|
||||
If this didn't happened on installation than go to the`admin/config/development/configuration/single/import` and manually import config from the file located in the module folder at: `config/optional/views.view.content_translations.yml`.
|
||||
|
||||
**Fields**
|
||||
The view display:
|
||||
- Title for each node in the view
|
||||
- The node language
|
||||
- The target language
|
||||
- The translation status of target language.
|
||||
- The time the content was last changed in target language
|
||||
- Translation operations to add/edit translation in target language
|
||||
|
||||
**Filters**
|
||||
Exposed filters:
|
||||
- Source language (the language of each node in the view)
|
||||
- Target language
|
||||
- Outdated status in target language
|
||||
- Translation status in target language
|
||||
|
||||
Hidden filters
|
||||
- Source content outdated must be false: Make sure you do not translation from outdated nodes.
|
||||
- Target language equals default language must be false: As there is no use to check status of original language as a target language.
|
||||
- The target language must be untranslated or outdated: Make sure translated and updated content disapear from the list.
|
||||
- The target language must be untranslated or the same as the source language of translation: This makes sure that once there is a translation in target language it will only be displayed if the source language is the correct source language. If target language is not translated you can use different language as source translation.
|
||||
|
||||
## Credits
|
||||
Developed by [vlad.dancer](https://drupal.org/u/vladdancer)
|
||||
Designed by [matsbla](https://drupal.org/u/matsbla)
|
||||
+952
@@ -0,0 +1,952 @@
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
- translation_views
|
||||
- user
|
||||
id: content_translations
|
||||
label: 'Content translation jobs'
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: nid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
options:
|
||||
perm: 'create content translations'
|
||||
cache:
|
||||
type: tag
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
query_tags: { }
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Apply
|
||||
reset_button: true
|
||||
reset_button_label: Reset
|
||||
exposed_sorts_label: 'Sort by'
|
||||
expose_sort_order: true
|
||||
sort_asc_label: Asc
|
||||
sort_desc_label: Desc
|
||||
pager:
|
||||
type: full
|
||||
options:
|
||||
items_per_page: 50
|
||||
offset: 0
|
||||
id: 0
|
||||
total_pages: null
|
||||
tags:
|
||||
previous: ‹‹
|
||||
next: ››
|
||||
first: '« First'
|
||||
last: 'Last »'
|
||||
expose:
|
||||
items_per_page: false
|
||||
items_per_page_label: 'Items per page'
|
||||
items_per_page_options: '5, 10, 25, 50'
|
||||
items_per_page_options_all: false
|
||||
items_per_page_options_all_label: '- All -'
|
||||
offset: false
|
||||
offset_label: Offset
|
||||
quantity: 9
|
||||
style:
|
||||
type: table
|
||||
options:
|
||||
grouping: { }
|
||||
row_class: ''
|
||||
default_row_class: true
|
||||
override: true
|
||||
sticky: false
|
||||
caption: ''
|
||||
summary: ''
|
||||
description: ''
|
||||
columns:
|
||||
title: title
|
||||
langcode: langcode
|
||||
translation_target_language: translation_target_language
|
||||
translation_outdated: translation_outdated
|
||||
translation_status: translation_status
|
||||
changed: changed
|
||||
translation_operations: translation_operations
|
||||
info:
|
||||
title:
|
||||
sortable: true
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
langcode:
|
||||
sortable: true
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
translation_target_language:
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
translation_outdated:
|
||||
sortable: false
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
translation_status:
|
||||
sortable: true
|
||||
default_sort_order: desc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
changed:
|
||||
sortable: true
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
translation_operations:
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
default: changed
|
||||
empty_table: false
|
||||
row:
|
||||
type: fields
|
||||
fields:
|
||||
title:
|
||||
id: title
|
||||
table: node_field_data
|
||||
field: title
|
||||
entity_type: node
|
||||
entity_field: title
|
||||
alter:
|
||||
alter_text: false
|
||||
make_link: false
|
||||
absolute: false
|
||||
trim: false
|
||||
word_boundary: false
|
||||
ellipsis: false
|
||||
strip_tags: false
|
||||
html: false
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
settings:
|
||||
link_to_entity: true
|
||||
plugin_id: field
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: Title
|
||||
exclude: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: string
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
langcode:
|
||||
id: langcode
|
||||
table: node_field_data
|
||||
field: langcode
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: From
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: language
|
||||
settings:
|
||||
link_to_entity: false
|
||||
native_language: false
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
entity_type: node
|
||||
entity_field: langcode
|
||||
plugin_id: field
|
||||
translation_target_language:
|
||||
id: translation_target_language
|
||||
table: node_translation
|
||||
field: translation_target_language
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: To
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
native_language: 0
|
||||
entity_type: node
|
||||
plugin_id: translation_views_target_language
|
||||
translation_outdated:
|
||||
id: translation_outdated
|
||||
table: node_translation_target
|
||||
field: translation_outdated
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: true
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
type: boolean
|
||||
type_custom_true: ''
|
||||
type_custom_false: ''
|
||||
not: false
|
||||
plugin_id: boolean
|
||||
translation_status:
|
||||
id: translation_status
|
||||
table: node_translation
|
||||
field: translation_status
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: 'Translation status'
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: true
|
||||
text: "<span class=\"status\">{{ translation_status }}</span>\n{% if translation_outdated %} <span class=\"marker\">{{ 'outdated'|t }}</span>{% endif %}"
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
type: status
|
||||
type_custom_true: ✅
|
||||
type_custom_false: ❌
|
||||
not: false
|
||||
plugin_id: boolean
|
||||
translation_changed:
|
||||
id: translation_changed
|
||||
table: node_translation_target
|
||||
field: translation_changed
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: Changed
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
date_format: fallback
|
||||
custom_date_format: ''
|
||||
timezone: ''
|
||||
entity_field: changed
|
||||
plugin_id: date
|
||||
translation_operations:
|
||||
id: translation_operations
|
||||
table: node_translation
|
||||
field: translation_operations
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: 'Translation operations'
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
destination: true
|
||||
entity_type: node
|
||||
plugin_id: translation_views_operations
|
||||
filters:
|
||||
langcode:
|
||||
id: langcode
|
||||
table: node_field_data
|
||||
field: langcode
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: in
|
||||
value: { }
|
||||
group: 1
|
||||
exposed: true
|
||||
expose:
|
||||
operator_id: langcode_op
|
||||
label: 'Source language'
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: langcode_op
|
||||
identifier: langcode
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
anonymous: '0'
|
||||
administrator: '0'
|
||||
reduce: false
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
entity_type: node
|
||||
entity_field: langcode
|
||||
plugin_id: language
|
||||
content_translation_outdated:
|
||||
id: content_translation_outdated
|
||||
table: node_field_data
|
||||
field: content_translation_outdated
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '0'
|
||||
group: 1
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: 'Translation outdated'
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: content_translation_outdated_op
|
||||
identifier: content_translation_outdated
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
anonymous: '0'
|
||||
administrator: '0'
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
entity_type: node
|
||||
entity_field: content_translation_outdated
|
||||
plugin_id: boolean
|
||||
translation_target_language:
|
||||
id: translation_target_language
|
||||
table: node_translation
|
||||
field: translation_target_language
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: { }
|
||||
group: 1
|
||||
exposed: true
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: 'Target language'
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: translation_target_language_op
|
||||
identifier: translation_target_language
|
||||
required: true
|
||||
remember: true
|
||||
multiple: true
|
||||
remember_roles:
|
||||
anonymous: anonymous
|
||||
authenticated: authenticated
|
||||
administrator: '0'
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
remove: 1
|
||||
entity_type: node
|
||||
plugin_id: translation_views_target_language
|
||||
translation_outdated:
|
||||
id: translation_outdated
|
||||
table: node_translation_target
|
||||
field: translation_outdated
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: All
|
||||
group: 1
|
||||
exposed: true
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: Outdated
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: translation_outdated_op
|
||||
identifier: translation_outdated
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
anonymous: '0'
|
||||
administrator: '0'
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
entity_field: content_translation_outdated
|
||||
plugin_id: boolean
|
||||
translation_status:
|
||||
id: translation_status
|
||||
table: node_translation
|
||||
field: translation_status
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '2'
|
||||
group: 1
|
||||
exposed: true
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: Translation status
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: translation_status_op
|
||||
identifier: translation_status
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
anonymous: '0'
|
||||
administrator: '0'
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
translation_target_language: false
|
||||
entity_type: node
|
||||
plugin_id: translation_views_status
|
||||
translation_default:
|
||||
id: translation_default
|
||||
table: node_translation_target
|
||||
field: translation_default
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '0'
|
||||
group: 1
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
plugin_id: boolean
|
||||
translation_status_1:
|
||||
id: translation_status_1
|
||||
table: node_translation
|
||||
field: translation_status
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '0'
|
||||
group: 2
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
entity_type: node
|
||||
plugin_id: translation_views_status
|
||||
translation_source:
|
||||
id: translation_source
|
||||
table: node_translation_target
|
||||
field: translation_source
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '1'
|
||||
group: 2
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
plugin_id: translation_views_source_equals_row
|
||||
translation_status_2:
|
||||
id: translation_status_2
|
||||
table: node_translation
|
||||
field: translation_status
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '0'
|
||||
group: 3
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
entity_type: node
|
||||
plugin_id: translation_views_status
|
||||
translation_outdated_1:
|
||||
id: translation_outdated_1
|
||||
table: node_translation_target
|
||||
field: translation_outdated
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value: '1'
|
||||
group: 3
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: ''
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
plugin_id: boolean
|
||||
sorts:
|
||||
created:
|
||||
id: created
|
||||
table: node_field_data
|
||||
field: created
|
||||
order: DESC
|
||||
entity_type: node
|
||||
entity_field: created
|
||||
plugin_id: date
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
exposed: false
|
||||
expose:
|
||||
label: ''
|
||||
granularity: second
|
||||
title: 'Content Translation jobs'
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
filter_groups:
|
||||
operator: AND
|
||||
groups:
|
||||
1: AND
|
||||
2: OR
|
||||
3: OR
|
||||
cache_metadata:
|
||||
max-age: 0
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- url.query_args
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
tags: { }
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: translate/content
|
||||
cache_metadata:
|
||||
max-age: 0
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- url.query_args
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
tags: { }
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
views.filter.translation_views_translation_count:
|
||||
type: views.filter.numeric
|
||||
label: 'Translation count'
|
||||
|
||||
views.filter_value.translation_views_translation_count:
|
||||
type: views.filter_value.numeric
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views;
|
||||
|
||||
use Drupal\content_translation\ContentTranslationHandlerInterface;
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
|
||||
/**
|
||||
* Class EntityInfo.
|
||||
*
|
||||
* Special object to store common entity related properties,
|
||||
* it will be used by all operations link builder functions,
|
||||
* just as "trait" but for method's values.
|
||||
*
|
||||
* @package Drupal\translation_views
|
||||
*/
|
||||
class EntityInfo {
|
||||
|
||||
/**
|
||||
* Source entity.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\ContentEntityInterface
|
||||
*/
|
||||
public $entity;
|
||||
|
||||
/**
|
||||
* The entity type id.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $entityTypeId;
|
||||
|
||||
/**
|
||||
* Entity type instance.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
*/
|
||||
public $entityType;
|
||||
|
||||
public $translations;
|
||||
|
||||
public $translatable;
|
||||
|
||||
public $rowLanguage;
|
||||
|
||||
public $access;
|
||||
|
||||
public $currentLanguage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(ContentEntityInterface $entity, ContentTranslationHandlerInterface $access, LanguageInterface $language, LanguageInterface $row_lang) {
|
||||
$this->entity = $entity;
|
||||
$this->access = $access;
|
||||
|
||||
$this->rowLanguage = $row_lang;
|
||||
$this->currentLanguage = $language;
|
||||
|
||||
$this->entityTypeId = $entity->getEntityTypeId();
|
||||
$this->entityType = $entity->getEntityType();
|
||||
$this->translations = $entity->getTranslationLanguages();
|
||||
$this->translatable = $entity->isTranslatable();
|
||||
}
|
||||
|
||||
/**
|
||||
* An wrapper to get translation access by particular entity per operation.
|
||||
*
|
||||
* @see \Drupal\content_translation\ContentTranslationHandlerInterface::getTranslationAccess,
|
||||
* for available operations.
|
||||
*/
|
||||
public function getTranslationAccess($op) {
|
||||
$access = $this->access->getTranslationAccess($this->entity, $op);
|
||||
return $access->isAllowed();
|
||||
}
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\translation_views\TranslationCountTrait;
|
||||
use Drupal\views\Plugin\views\field\NumericField;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\views\Plugin\ViewsHandlerManager;
|
||||
|
||||
/**
|
||||
* Show translation count.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* @ViewsField("translation_views_translation_count")
|
||||
*/
|
||||
class TranslationCountField extends NumericField implements ContainerFactoryPluginInterface {
|
||||
use TranslationCountTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ViewsHandlerManager $join_handler) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->joinHandler = $join_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration, $plugin_id, $plugin_definition,
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('plugin.manager.views.join')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
/** @var \Drupal\views\Plugin\views\query\Sql $query */
|
||||
$query = $this->query;
|
||||
$join_alias = $this->joinLanguages($query);
|
||||
$this->field_alias = $query->addField($join_alias, 'count_langs', $this->realField);
|
||||
}
|
||||
|
||||
}
|
||||
+241
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\translation_views\EntityInfo as HelperEntityInfo;
|
||||
use Drupal\translation_views\TranslationViewsTargetLanguage as TargetLanguage;
|
||||
use Drupal\views\Plugin\views\field\EntityOperations;
|
||||
use Drupal\views\ResultRow;
|
||||
|
||||
/**
|
||||
* Renders translation operations links.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* @ViewsField("translation_views_operations")
|
||||
*/
|
||||
class TranslationOperationsField extends EntityOperations {
|
||||
use TargetLanguage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Build operation links.
|
||||
*/
|
||||
public function render(ResultRow $values) {
|
||||
/* @var ContentEntityInterface $entity */
|
||||
$entity = $this->getEntity($values);
|
||||
$langcode_key = $this->buildSourceEntityLangcodeKey($entity);
|
||||
$operations = $this->getOperations($entity, $values->{$langcode_key});
|
||||
|
||||
if ($this->options['destination']) {
|
||||
foreach ($operations as &$operation) {
|
||||
if (!isset($operation['query'])) {
|
||||
$operation['query'] = [];
|
||||
}
|
||||
$operation['query'] += $this->getDestinationArray();
|
||||
}
|
||||
}
|
||||
$build = [
|
||||
'#type' => 'operations',
|
||||
'#links' => $operations,
|
||||
];
|
||||
$build['#cache']['contexts'][] = 'url.query_args:target_language';
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build value key.
|
||||
*
|
||||
* Value key based on base table,
|
||||
* and system name of langcode key (it might be differ then just 'langcode'),
|
||||
* usually table alias is [entity_type]_field_data_[langcode_key].
|
||||
*
|
||||
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
|
||||
* Used to extract entity type info from entity.
|
||||
*
|
||||
* @return string
|
||||
* The value key.
|
||||
*/
|
||||
protected function buildSourceEntityLangcodeKey(ContentEntityInterface $entity) {
|
||||
return implode('_', [
|
||||
$this->view->storage->get('base_table'),
|
||||
$entity->getEntityType()->getKey('langcode'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation links manager.
|
||||
*
|
||||
* Decide which links we should generate:
|
||||
* based on user permissions,
|
||||
* and entity state (has translation, is default, etc.).
|
||||
*
|
||||
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
|
||||
* The source entity to get context for decision.
|
||||
* @param string $row_lang
|
||||
* The target langcode of the row.
|
||||
*
|
||||
* @return array
|
||||
* Operation links' render array.
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
|
||||
* @throws \Drupal\Core\Entity\EntityMalformedException
|
||||
*/
|
||||
protected function getOperations(ContentEntityInterface $entity, $row_lang) {
|
||||
$links = [];
|
||||
$current = $this->getTargetLanguage()
|
||||
? $this->getTargetLanguage()
|
||||
: $row_lang;
|
||||
|
||||
/* @var \Drupal\content_translation\ContentTranslationHandlerInterface $handler */
|
||||
$handler = $this->getEntityManager()
|
||||
->getHandler($entity->getEntityTypeId(), 'translation');
|
||||
|
||||
// Construct special object to store common properties,
|
||||
// it will be used by all builder functions,
|
||||
// just as "trait" but for methods.
|
||||
$entity_info = new HelperEntityInfo(
|
||||
$entity,
|
||||
$handler,
|
||||
$this->languageManager->getLanguage($current),
|
||||
$this->languageManager->getLanguage($row_lang)
|
||||
);
|
||||
|
||||
$is_source = $entity->getUntranslated()->language()->getId() === $entity_info->rowLanguage->getId();
|
||||
|
||||
// Build edit & delete link.
|
||||
if (array_key_exists($current, $entity_info->translations)) {
|
||||
// If the user is allowed to edit the entity we point the edit link to
|
||||
// the entity form, otherwise if we are not dealing with the original
|
||||
// language we point the link to the translation form.
|
||||
if ($entity->access('update', NULL, TRUE)->isAllowed()
|
||||
&& $entity_info->entityType->hasLinkTemplate('edit-form')
|
||||
) {
|
||||
$links += $this->buildEditLink($entity_info, 'entity');
|
||||
}
|
||||
elseif (!$is_source && $entity_info->getTranslationAccess('update')) {
|
||||
$links += $this->buildEditLink($entity_info, 'translation');
|
||||
}
|
||||
|
||||
// Build delete link.
|
||||
if (!$is_source) {
|
||||
if ($entity->access('delete')
|
||||
&& $entity_info->entityType->hasLinkTemplate('delete-form')
|
||||
) {
|
||||
$links += $this->buildDeleteLink($entity_info, 'entity');
|
||||
}
|
||||
elseif ($entity_info->getTranslationAccess('update')) {
|
||||
$links += $this->buildDeleteLink($entity_info, 'translation');
|
||||
}
|
||||
}
|
||||
}
|
||||
// Build add link.
|
||||
elseif (!empty($current)
|
||||
&& $entity_info->translatable
|
||||
&& $entity_info->getTranslationAccess('create')
|
||||
) {
|
||||
// No such translation.
|
||||
$links += $this->buildAddLink($entity_info);
|
||||
}
|
||||
return $links;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add link builder.
|
||||
*/
|
||||
protected function buildAddLink(HelperEntityInfo $entity_info) {
|
||||
$links = [];
|
||||
|
||||
$add_url = new Url(
|
||||
"entity.{$entity_info->entityTypeId}.content_translation_add",
|
||||
[
|
||||
'source' => $entity_info->rowLanguage->getId(),
|
||||
'target' => $entity_info->currentLanguage->getId(),
|
||||
$entity_info->entityTypeId => $entity_info->entity->id(),
|
||||
],
|
||||
[
|
||||
'language' => $entity_info->currentLanguage,
|
||||
]
|
||||
);
|
||||
|
||||
$links['add'] = [
|
||||
'title' => $this->t('Add'),
|
||||
'url' => $add_url,
|
||||
];
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete link builder.
|
||||
*/
|
||||
protected function buildDeleteLink(HelperEntityInfo $entity_info, $type = FALSE) {
|
||||
$links = [];
|
||||
|
||||
if (!$type) {
|
||||
return $links;
|
||||
}
|
||||
|
||||
if ($type == 'entity') {
|
||||
$links['delete'] = [
|
||||
'title' => $this->t('Delete'),
|
||||
'url' => $entity_info->entity->urlInfo('delete-form'),
|
||||
'language' => $entity_info->rowLanguage,
|
||||
];
|
||||
}
|
||||
elseif ($type == 'translation') {
|
||||
$links['delete'] = [
|
||||
'title' => $this->t('Delete'),
|
||||
'url' => new Url(
|
||||
"entity.{$entity_info->entityTypeId}.content_translation_delete",
|
||||
[
|
||||
'language' => $entity_info->rowLanguage->getId(),
|
||||
$entity_info->entityTypeId => $entity_info->entity->id(),
|
||||
],
|
||||
[
|
||||
'language' => $entity_info->rowLanguage,
|
||||
]
|
||||
),
|
||||
];
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit link builder.
|
||||
*
|
||||
* @throws \Drupal\Core\Entity\EntityMalformedException
|
||||
*/
|
||||
protected function buildEditLink(HelperEntityInfo $entity_info, $type = FALSE) {
|
||||
$links = [];
|
||||
|
||||
if ($type == 'entity') {
|
||||
$links['edit']['url'] = $entity_info->entity->toUrl('edit-form');
|
||||
$links['edit']['language'] = $entity_info->rowLanguage;
|
||||
}
|
||||
elseif ($type == 'translation') {
|
||||
$links['edit']['url'] = new Url(
|
||||
"entity.{$entity_info->entityTypeId}.content_translation_edit",
|
||||
[
|
||||
'language' => $entity_info->rowLanguage->getId(),
|
||||
$entity_info->entityTypeId => $entity_info->entity->id(),
|
||||
],
|
||||
[
|
||||
'language' => $entity_info->rowLanguage,
|
||||
]
|
||||
);
|
||||
;
|
||||
}
|
||||
|
||||
if (isset($links['edit'])) {
|
||||
$links['edit']['title'] = $this->t('Edit');
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\field;
|
||||
|
||||
use Drupal\views\Plugin\views\display\DisplayPluginBase;
|
||||
use Drupal\views\Plugin\views\field\Boolean;
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
||||
/**
|
||||
* Provides a field that adds translation status.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* @ViewsField("translation_views_source_equals_row")
|
||||
*/
|
||||
class TranslationSourceLangcodeEqualsRowLangcodeField extends Boolean {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
|
||||
parent::init($view, $display, $options);
|
||||
$this->field_alias = 'source_lang_eq_row';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['type'] = ['default' => 'status'];
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$table_alias = $this->ensureMyTable();
|
||||
$base_table = $this->view->storage->get('base_table');
|
||||
|
||||
$this->query->addField(
|
||||
NULL,
|
||||
"IF($table_alias.content_translation_source = $base_table.langcode, 1, 0)",
|
||||
'source_lang_eq_row'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\TypedData\TranslationStatusInterface;
|
||||
use Drupal\views\Plugin\views\display\DisplayPluginBase;
|
||||
use Drupal\views\Plugin\views\field\Boolean;
|
||||
use Drupal\translation_views\TranslationViewsTargetLanguage as TargetLanguage;
|
||||
use Drupal\views\ResultRow;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Provides a field that adds translation status.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* @ViewsField("translation_views_status")
|
||||
*/
|
||||
class TranslationStatus extends Boolean implements ContainerFactoryPluginInterface {
|
||||
use TargetLanguage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration, $plugin_id, $plugin_definition,
|
||||
$container->get('language_manager')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, LanguageManagerInterface $language_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->languageManager = $language_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['type'] = ['default' => 'status'];
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
|
||||
$this->definition['output formats']['status'] = [
|
||||
t('Translated'), $this->t('Not translated'),
|
||||
];
|
||||
$this->field_alias = 'translation_status';
|
||||
|
||||
parent::init($view, $display, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Convert translation status value into TranslationStatusInterface values.
|
||||
*/
|
||||
public function render(ResultRow $values) {
|
||||
$values->{$this->field_alias} = $values->{$this->field_alias} > 0
|
||||
? TranslationStatusInterface::TRANSLATION_EXISTING
|
||||
: NULL;
|
||||
return parent::render($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Expression wouldn't work without:
|
||||
*
|
||||
* @see translation_views_query_views_alter()
|
||||
*/
|
||||
public function query() {
|
||||
$table_alias = $this->ensureMyTable();
|
||||
$this->query->addField(
|
||||
NULL,
|
||||
"FIND_IN_SET(:langcode, $table_alias.langs) > 0",
|
||||
'translation_status',
|
||||
[
|
||||
'placeholders' => [':langcode' => '***TRANSLATION_VIEWS_TARGET_LANG***'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\views\Plugin\views\field\LanguageField;
|
||||
use Drupal\views\ResultRow;
|
||||
use Drupal\translation_views\TranslationViewsTargetLanguage as TargetLanguage;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Target Translation langcode field.
|
||||
*
|
||||
* Defines a field handler to translate a translation language,
|
||||
* into its readable form.
|
||||
*
|
||||
* This field handler just gets a value from exposed input and show it,
|
||||
* if doesn't make any database query.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* @ViewsField("translation_views_target_language")
|
||||
*/
|
||||
class TranslationTargetLanguageField extends LanguageField implements ContainerFactoryPluginInterface {
|
||||
use TargetLanguage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration, $plugin_id, $plugin_definition,
|
||||
$container->get('language_manager')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, LanguageManagerInterface $language_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->languageManager = $language_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function usesGroupBy() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Override parent to get langcode from exposed input,
|
||||
* instead from ResultRow.
|
||||
*/
|
||||
public function render(ResultRow $values) {
|
||||
$target_lang = $this->getTargetLanguage();
|
||||
|
||||
$languages = $this->options['native_language']
|
||||
? $this->languageManager->getNativeLanguages()
|
||||
: $this->languageManager->getLanguages();
|
||||
|
||||
$build['#markup'] = $languages[$target_lang]->getName();
|
||||
$build['#cache']['contexts'][] = 'url.query_args:' . self::$targetExposedKey;
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clickSortable() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\filter;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\translation_views\TranslationCountTrait;
|
||||
use Drupal\views\Plugin\views\filter\NumericFilter;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\views\Plugin\ViewsHandlerManager;
|
||||
|
||||
/**
|
||||
* Translation count filter.
|
||||
*
|
||||
* Filter rows by number of exisitng translations for a given source entity.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* @ViewsFilter("translation_views_translation_count")
|
||||
*/
|
||||
class TranslationCountFilter extends NumericFilter implements ContainerFactoryPluginInterface {
|
||||
use TranslationCountTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration, $plugin_id, $plugin_definition,
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('plugin.manager.views.join')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ViewsHandlerManager $join_handler) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->joinHandler = $join_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
/** @var \Drupal\views\Plugin\views\query\Sql $query */
|
||||
$query = $this->query;
|
||||
$op = $this->operator;
|
||||
|
||||
$join_alias = $this->joinLanguages($query);
|
||||
|
||||
$query->addWhereExpression(
|
||||
$this->options['group'],
|
||||
"IF(ISNULL($join_alias.count_langs), 0, $join_alias.count_langs) $op :value",
|
||||
[':value' => $this->value['value']]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\filter;
|
||||
|
||||
use Drupal\views\Plugin\views\filter\BooleanOperator;
|
||||
|
||||
/**
|
||||
* Filter rows by equity of two langcodes.
|
||||
*
|
||||
* The source and target langcodes is used for comparision.
|
||||
*
|
||||
* @ViewsFilter("translation_views_source_equals_row")
|
||||
*/
|
||||
class TranslationSourceLangcodeEqualsRowLangcodeFilter extends BooleanOperator {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$table_alias = $this->ensureMyTable();
|
||||
$base_table = $this->view->storage->get('base_table');
|
||||
|
||||
$this->query->addWhereExpression(
|
||||
$this->options['group'],
|
||||
"IF($table_alias.content_translation_source $this->operator $base_table.langcode, 1, 0) = :value", [
|
||||
':value' => $this->value,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\filter;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\views\Plugin\views\filter\FilterPluginBase;
|
||||
|
||||
/**
|
||||
* Provides filtering by translation status.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*
|
||||
* @ViewsFilter("translation_views_status")
|
||||
*/
|
||||
class TranslationStatusFilter extends FilterPluginBase {
|
||||
|
||||
const VALUE_UNTRANSLATED = 0;
|
||||
const VALUE_TRANSLATED = 1;
|
||||
const VALUE_BOTH = 2;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildExposeForm(&$form, FormStateInterface $form_state) {
|
||||
parent::buildExposeForm($form, $form_state);
|
||||
|
||||
unset($form['expose']['multiple']);
|
||||
unset($form['expose']['required']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['value']['default'] = FALSE;
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Remove "all" option because we don't need it.
|
||||
*/
|
||||
public function buildExposedForm(&$form, FormStateInterface $form_state) {
|
||||
parent::buildExposedForm($form, $form_state);
|
||||
|
||||
if (!empty($this->options['expose']['identifier'])) {
|
||||
$value_id = $this->options['expose']['identifier'];
|
||||
}
|
||||
else {
|
||||
$value_id = 'translation_views_status';
|
||||
}
|
||||
|
||||
unset($form[$value_id]['#options']['All']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function valueForm(&$form, FormStateInterface $form_state) {
|
||||
parent::valueForm($form, $form_state);
|
||||
|
||||
$exposed = $form_state->get('exposed');
|
||||
|
||||
if (!empty($this->options['exposed'])) {
|
||||
$identifier = $this->options['expose']['identifier'];
|
||||
$user_input = $form_state->getUserInput();
|
||||
|
||||
// We need set exposed input to our "BOTH" value,
|
||||
// when there is no selected value by user yet,
|
||||
// usually when there is no any changes in exposed filters.
|
||||
if ($exposed && !isset($user_input[$identifier])) {
|
||||
$user_input = $form_state->getUserInput();
|
||||
$user_input[$identifier] = self::VALUE_BOTH;
|
||||
|
||||
$form_state->setUserInput($user_input);
|
||||
$this->view->setExposedInput($user_input);
|
||||
}
|
||||
}
|
||||
|
||||
$form['value'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Status'),
|
||||
'#options' => [
|
||||
self::VALUE_BOTH => t('Both'),
|
||||
self::VALUE_UNTRANSLATED => t('Not translated'),
|
||||
self::VALUE_TRANSLATED => t('Translated'),
|
||||
],
|
||||
'#multiple' => FALSE,
|
||||
'#default_value' => $this->value,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$table_alias = $this->ensureMyTable();
|
||||
|
||||
$status = is_array($this->value)
|
||||
? (int) reset($this->value)
|
||||
: $this->value;
|
||||
|
||||
// We don't want to build and run query,
|
||||
// when user specified both statuses.
|
||||
if ($status == self::VALUE_BOTH) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($status == self::VALUE_UNTRANSLATED) {
|
||||
$op = '=';
|
||||
}
|
||||
// Then self::VALUE_TRANSLATED is the case.
|
||||
else {
|
||||
// Mysql FIND_IN_SET func will return position of element,
|
||||
// when no element was found then it returns 0,
|
||||
// so we use "> 0" as condition to filter out untranslated rows.
|
||||
$op = '>';
|
||||
$status = 0;
|
||||
}
|
||||
|
||||
/* @var \Drupal\views\Plugin\views\query\Sql */
|
||||
$this->query->addWhereExpression(
|
||||
$this->options['group'],
|
||||
"FIND_IN_SET(:langcode, $table_alias.langs) $op :status", [
|
||||
':langcode' => '***TRANSLATION_VIEWS_TARGET_LANG***',
|
||||
':status' => $status,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\filter;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\views\Plugin\views\filter\FilterPluginBase;
|
||||
use Drupal\translation_views\TranslationViewsTargetLanguage as TargetLanguage;
|
||||
use Drupal\views\Plugin\views\PluginBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Provides filtering by translation target language.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*
|
||||
* @ViewsFilter("translation_views_target_language")
|
||||
*/
|
||||
class TranslationTargetLanguageFilter extends FilterPluginBase implements ContainerFactoryPluginInterface {
|
||||
use TargetLanguage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration, $plugin_id, $plugin_definition,
|
||||
$container->get('language_manager')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, LanguageManagerInterface $language_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->languageManager = $language_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildExposeForm(&$form, FormStateInterface $form_state) {
|
||||
parent::buildExposeForm($form, $form_state);
|
||||
|
||||
unset($form['expose']['multiple']);
|
||||
unset($form['expose']['required']);
|
||||
|
||||
$form['expose']['identifier'] = [
|
||||
'#type' => 'hidden',
|
||||
'#value' => $this->options['expose']['identifier'],
|
||||
'#title' => $this->t('Filter identifier'),
|
||||
'#size' => 40,
|
||||
'#description' => $this->t('This will appear in the URL after the ? to identify this filter. Cannot be blank. Only letters, digits and the dot ("."), hyphen ("-"), underscore ("_"), and tilde ("~") characters are allowed.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['expose']['identifier'] = static::$targetExposedKey;
|
||||
$options['value']['default'] = '';
|
||||
$options['remove']['default'] = FALSE;
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function valueForm(&$form, FormStateInterface $form_state) {
|
||||
parent::valueForm($form, $form_state);
|
||||
|
||||
$exposed = $form_state->get('exposed');
|
||||
|
||||
if (!empty($this->options['exposed'])) {
|
||||
$identifier = $this->options['expose']['identifier'];
|
||||
$user_input = $form_state->getUserInput();
|
||||
|
||||
// We need set exposed input when there is no selected value by user yet.
|
||||
if ($exposed && !isset($user_input[$identifier])) {
|
||||
$value = PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT;
|
||||
$this->setExposedValue($identifier, $value, $form_state);
|
||||
}
|
||||
}
|
||||
|
||||
$form['value'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Target language'),
|
||||
'#options' => $this->buildLanguageOptions(),
|
||||
'#multiple' => FALSE,
|
||||
'#weight' => 0,
|
||||
'#default_value' => $this->value,
|
||||
];
|
||||
|
||||
if (!$exposed) {
|
||||
$form['remove'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Remove rows where source language is equal to target language.'),
|
||||
'#default_value' => $this->options['remove'],
|
||||
'#weight' => -50,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide options for langcode dropdown.
|
||||
*
|
||||
* Options are based on configurable languages or site default one.
|
||||
*/
|
||||
protected function buildLanguageOptions() {
|
||||
$site_default = $this->languageManager->getDefaultLanguage();
|
||||
$options = $this->listLanguages(LanguageInterface::STATE_CONFIGURABLE);
|
||||
|
||||
if (isset($options[$site_default->getId()])) {
|
||||
unset($options[$site_default->getId()]);
|
||||
}
|
||||
|
||||
return [PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT => $site_default->getName()] + $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
if ($this->options['remove']) {
|
||||
$this->query->addWhere(
|
||||
$this->options['group'],
|
||||
$this->view->storage->get('base_table') . '.langcode',
|
||||
'***TRANSLATION_VIEWS_TARGET_LANG***',
|
||||
'<>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Special setter for exposed value in views.
|
||||
*/
|
||||
protected function setExposedValue($identifier, $value, FormStateInterface $form_state) {
|
||||
$user_input = $form_state->getUserInput();
|
||||
$user_input[$identifier] = $value;
|
||||
|
||||
$form_state->setUserInput($user_input);
|
||||
$this->view->setExposedInput($user_input);
|
||||
}
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views\Plugin\views\join;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\views\Plugin\views\join\JoinPluginBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Special join to show all translatable langcodes per one row.
|
||||
*
|
||||
* @ViewsJoin("translation_views_language_join")
|
||||
*/
|
||||
class TranslationLanguageJoin extends JoinPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* Database connection.
|
||||
*
|
||||
* @var \Drupal\Core\Database\Connection
|
||||
*/
|
||||
protected $database;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('database')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildJoin($select_query, $table, $view_query) {
|
||||
$query = $this->database->select($this->table, 'nfd');
|
||||
$query->fields('nfd', ['nid']);
|
||||
|
||||
if (!empty($this->configuration['langcodes_as_count'])) {
|
||||
$query->addExpression("COUNT(nfd.langcode)", 'count_langs');
|
||||
}
|
||||
else {
|
||||
$query->addExpression("GROUP_CONCAT(nfd.langcode separator ',')", 'langs');
|
||||
}
|
||||
|
||||
if (!empty($this->configuration['exclude_default_langcode'])) {
|
||||
$query->where('nfd.default_langcode != 1');
|
||||
}
|
||||
|
||||
$query->groupBy('nfd.nid');
|
||||
$this->configuration['table formula'] = $query;
|
||||
|
||||
parent::buildJoin($select_query, $table, $view_query);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views;
|
||||
|
||||
use Drupal\views\Plugin\views\query\Sql as ViewsSqlQuery;
|
||||
|
||||
/**
|
||||
* Defines translation count trait.
|
||||
*
|
||||
* Used to check if table translations already have joined,
|
||||
* if not force to join.
|
||||
*/
|
||||
trait TranslationCountTrait {
|
||||
|
||||
/**
|
||||
* Translation table alias.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tableAlias = 'translations';
|
||||
|
||||
/**
|
||||
* Ensure that translations table is joined.
|
||||
*
|
||||
* @param \Drupal\views\Plugin\views\query\Sql $query
|
||||
* Views sql query.
|
||||
*
|
||||
* @return string
|
||||
* The table alias after joining a table.
|
||||
*/
|
||||
protected function joinLanguages(ViewsSqlQuery &$query) {
|
||||
if (empty($query->tables[$this->tableAlias])) {
|
||||
$query_base_table = $this->relationship ?: $this->view->storage->get('base_table');
|
||||
|
||||
$entity_type = $this->entityTypeManager->getDefinition($this->getEntityType());
|
||||
$keys = $entity_type->getKeys();
|
||||
|
||||
$definition = [
|
||||
'type' => 'LEFT',
|
||||
'left_field' => $keys['id'],
|
||||
'field' => $keys['id'],
|
||||
'table' => $query_base_table,
|
||||
'left_table' => $query_base_table,
|
||||
'exclude_default_langcode' => TRUE,
|
||||
'langcodes_as_count' => TRUE,
|
||||
];
|
||||
|
||||
$tableAlias = $query->ensureTable($query_base_table, $this->relationship);
|
||||
$join = $this->joinHandler->createInstance('translation_views_language_join', $definition);
|
||||
|
||||
return $query->addTable($query_base_table, $tableAlias, $join, $this->tableAlias);
|
||||
}
|
||||
else {
|
||||
return $this->tableAlias;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views;
|
||||
|
||||
/**
|
||||
* Class TranslationViewsFieldDefinitions.
|
||||
*
|
||||
* @package Drupal\translation_views
|
||||
*/
|
||||
final class TranslationViewsFieldDefinitions {
|
||||
|
||||
/**
|
||||
* Ttranslation status field definition.
|
||||
*/
|
||||
public static function buildStatusField() {
|
||||
return [
|
||||
'translation_status' => [
|
||||
'field_name' => 'status',
|
||||
'real field' => 'langcode',
|
||||
'title' => t('Translation status'),
|
||||
'field' => [
|
||||
'id' => 'translation_views_status',
|
||||
'help' => t('A boolean indicating whether the node is translated into target language.'),
|
||||
'additional fields' => [
|
||||
'content_translation_source' => 'content_translation_source',
|
||||
],
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'translation_views_status',
|
||||
'help' => t('A boolean indicating whether the node is translated into target language.'),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Translations count field definition.
|
||||
*/
|
||||
public static function buildCountField() {
|
||||
return [
|
||||
'translation_count' => [
|
||||
'field_name' => 'counter',
|
||||
'real field' => 'translation_langs',
|
||||
'title' => t('Translation counter'),
|
||||
'field' => [
|
||||
'id' => 'translation_views_translation_count',
|
||||
'help' => t('Amount of translations (without default language).'),
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'translation_views_translation_count',
|
||||
'help' => t('Filter rows by amount of translations (without default language).'),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation changed field definition.
|
||||
*/
|
||||
public static function buildChangedField($definition) {
|
||||
$field = [];
|
||||
$field['translation_changed'] = $definition;
|
||||
$field['translation_changed']['real field'] = 'changed';
|
||||
$field['translation_changed']['field']['id'] = 'date';
|
||||
$field['translation_changed']['field']['help'] = t('The time that the node was last edited in target language.');
|
||||
$field['translation_changed']['title'] = t('Translation changed time');
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation outdated field definition.
|
||||
*/
|
||||
public static function buildOutdatedField($definition) {
|
||||
$field = [];
|
||||
$field['translation_outdated'] = $definition;
|
||||
$field['translation_outdated']['real field'] = 'content_translation_outdated';
|
||||
$field['translation_outdated']['field']['id'] = 'boolean';
|
||||
$field['translation_outdated']['filter']['id'] = 'boolean';
|
||||
$field['translation_outdated']['field']['help'] = t('A boolean indicating whether the target language translation is outdated');
|
||||
$field['translation_outdated']['filter']['help'] = t('A boolean indicating whether the target language translation is outdated');
|
||||
$field['translation_outdated']['title'] = t('Translation outdated');
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation source field definition.
|
||||
*/
|
||||
public static function buildSourceField($definition) {
|
||||
$field = [];
|
||||
$field['translation_source'] = $definition;
|
||||
$field['translation_source']['real field'] = 'content_translation_source';
|
||||
$field['translation_source']['field']['id'] = 'translation_views_source_equals_row';
|
||||
$field['translation_source']['filter']['id'] = 'translation_views_source_equals_row';
|
||||
$field['translation_source']['field']['help'] = t('A boolean indicating whether the translation source of target language is same as the row language');
|
||||
$field['translation_source']['filter']['help'] = t('A boolean indicating whether the translation source of target language is same as the row language');
|
||||
$field['translation_source']['title'] = t('Translation source equals row language');
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation default langcode field definition.
|
||||
*/
|
||||
public static function buildDefaultLangcodeField($definition) {
|
||||
$field = [];
|
||||
$field['translation_default'] = $definition;
|
||||
$field['translation_default']['real field'] = 'default_langcode';
|
||||
$field['translation_default']['field']['id'] = 'boolean';
|
||||
$field['translation_default']['filter']['id'] = 'boolean';
|
||||
$field['translation_default']['filter']['accept null'] = TRUE;
|
||||
$field['translation_default']['field']['help'] = t('A boolean indicating whether the target language is default language');
|
||||
$field['translation_default']['filter']['help'] = t('A boolean indicating whether the target language is default language');
|
||||
$field['translation_default']['title'] = t('Target language equals default language');
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation operations field definition.
|
||||
*/
|
||||
public static function buildOpLinksField() {
|
||||
$field['translation_operations'] = [
|
||||
'title' => t('Translation operations'),
|
||||
'help' => t('Provides links to perform translation operations.'),
|
||||
'field' => [
|
||||
'id' => 'translation_views_operations',
|
||||
],
|
||||
];
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation target language field definition.
|
||||
*/
|
||||
public static function buildTargetLanguageField() {
|
||||
$field['translation_target_language']['field'] = [
|
||||
'title' => t('Target language'),
|
||||
'id' => 'translation_views_target_language',
|
||||
'help' => t('The target language.'),
|
||||
];
|
||||
$field['translation_target_language']['filter'] = [
|
||||
'title' => t('Target language'),
|
||||
'id' => 'translation_views_target_language',
|
||||
'help' => t('Define the target language for other translation fields/filters. This filter should in most cases be used only as exposed filter.'),
|
||||
];
|
||||
return $field;
|
||||
}
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\translation_views;
|
||||
|
||||
use Drupal\views\Plugin\views\PluginBase;
|
||||
|
||||
/**
|
||||
* Trait TranslationViewsTargetLanguage.
|
||||
*
|
||||
* Used to give ability to get selected target langcode,
|
||||
* used by different different fields, filters.
|
||||
*
|
||||
* @package Drupal\translation_views
|
||||
*/
|
||||
trait TranslationViewsTargetLanguage {
|
||||
|
||||
/**
|
||||
* The language manager.
|
||||
*
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
public static $targetExposedKey = 'translation_target_language';
|
||||
|
||||
/**
|
||||
* Get target language from exposed input.
|
||||
*
|
||||
* @return string
|
||||
* Current selected target langcode
|
||||
*/
|
||||
protected function getTargetLanguage() {
|
||||
$inputs = $this->view->getExposedInput();
|
||||
$langcode = $inputs[self::$targetExposedKey];
|
||||
|
||||
return $langcode == PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT
|
||||
? $this->languageManager->getDefaultLanguage()->getId()
|
||||
: $langcode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
name: Translation Views
|
||||
type: module
|
||||
description: Create customized lists and queries of translations from your database.
|
||||
# core: 8.x
|
||||
package: Multilingual
|
||||
dependencies:
|
||||
- drupal:content_translation
|
||||
- drupal:views
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-02-13
|
||||
version: '8.x-1.0-alpha1'
|
||||
core: '8.x'
|
||||
project: 'translation_views'
|
||||
datestamp: 1518516495
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide hooks for translation_views module.
|
||||
*
|
||||
* Basicaly this file only used as workaround for this issue:
|
||||
* https://www.drupal.org/node/2325463.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Query\AlterableInterface;
|
||||
use Drupal\Core\Entity\ContentEntityFormInterface;
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_module_implements_alter().
|
||||
*/
|
||||
function translation_views_module_implements_alter(&$implementations, $hook) {
|
||||
switch ($hook) {
|
||||
// Move our hook_form_alter() implementation to the end of the list.
|
||||
case 'form_alter':
|
||||
$group = $implementations['translation_views'];
|
||||
unset($implementations['translation_views']);
|
||||
$implementations['translation_views'] = $group;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*
|
||||
* Add our submit for "source_langcode" submit.
|
||||
*/
|
||||
function translation_views_form_alter(&$form, FormStateInterface $form_state) {
|
||||
$form_object = $form_state->getFormObject();
|
||||
|
||||
if (!($form_object instanceof ContentEntityFormInterface)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$entity = $form_object->getEntity();
|
||||
$op = $form_object->getOperation();
|
||||
|
||||
if ($entity instanceof ContentEntityInterface
|
||||
&& $entity->isTranslatable()
|
||||
&& count($entity->getTranslationLanguages()) > 1
|
||||
&& in_array($op, ['edit', 'add', 'default'], TRUE)
|
||||
) {
|
||||
$form['source_langcode']['submit']['#submit'][] = 'translation_views_content_form_fix_destination';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit callback for "source_langcode" button.
|
||||
*/
|
||||
function translation_views_content_form_fix_destination($form, FormStateInterface $form_state) {
|
||||
/* @var \Drupal\Core\Entity\ContentEntityFormInterface $form_object */
|
||||
/* @var \Drupal\Core\Entity\ContentEntityInterface $entity */
|
||||
/* @var \Symfony\Component\HttpFoundation\ParameterBag $query */
|
||||
$form_object = $form_state->getFormObject();
|
||||
$entity = $form_object->getEntity();
|
||||
$source = $form_state->getValue(['source_langcode', 'source']);
|
||||
$query = \Drupal::service('request_stack')->getCurrentRequest()->query;
|
||||
$options = [];
|
||||
|
||||
// Remove destination parameter from request,
|
||||
// to allow "Change" button works like desired,
|
||||
// see similar issue here: https://www.drupal.org/node/2325463.
|
||||
// @todo: Create core issue for the content_translation module.
|
||||
if ($query->has('destination')) {
|
||||
$options['query']['destination'] = $query->get('destination');
|
||||
$query->remove('destination');
|
||||
}
|
||||
|
||||
$entity_type_id = $entity->getEntityTypeId();
|
||||
$form_state->setRedirect("entity.$entity_type_id.content_translation_add", [
|
||||
$entity_type_id => $entity->id(),
|
||||
'source' => $source,
|
||||
'target' => $form_object->getFormLangcode($form_state),
|
||||
], $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_query_TAG_alter().
|
||||
*
|
||||
* Add support to use views query substitutions in expressions
|
||||
* from hook_views_query_substitutions().
|
||||
* Expressions can be used in views fields (i.e addField()),
|
||||
* and views orderBy formula (i.e addOrderBy()).
|
||||
*
|
||||
* @todo Remove this workaround when will be solved in drupal core.
|
||||
*/
|
||||
function translation_views_query_views_alter(AlterableInterface $query) {
|
||||
$substitutions = $query->getMetaData('views_substitutions');
|
||||
$expressions =& $query->getExpressions();
|
||||
|
||||
foreach ($expressions as $field_id => &$item) {
|
||||
foreach ($item['arguments'] as $replacement_key => $value) {
|
||||
if (!is_array($value)) {
|
||||
if (isset($substitutions[$value])) {
|
||||
$expressions[$field_id]['arguments'][$replacement_key] = $substitutions[$value];
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($value as $sub_key => $sub_value) {
|
||||
if (isset($substitutions[$sub_value])) {
|
||||
$expressions[$field_id]['arguments'][$replacement_key][$sub_key] = $substitutions[$sub_value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide views extra filters/fields for translator needs.
|
||||
*
|
||||
* @ingroup views_module_handlers
|
||||
*/
|
||||
|
||||
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException as PluginNotFound;
|
||||
use Drupal\translation_views\TranslationViewsFieldDefinitions as FieldDefinitions;
|
||||
|
||||
/**
|
||||
* Implements hook_views_data_alter().
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
|
||||
*/
|
||||
function translation_views_views_data_alter(array &$data) {
|
||||
$content_translation_manager = \Drupal::service('content_translation.manager');
|
||||
|
||||
foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
if ($entity_type->hasHandlerClass('views_data')
|
||||
&& $entity_type->isTranslatable()
|
||||
&& $content_translation_manager->isEnabled($entity_type_id)
|
||||
) {
|
||||
|
||||
try {
|
||||
/** @var \Drupal\views\EntityViewsDataInterface $views_data */
|
||||
$views_data = \Drupal::entityTypeManager()->getHandler(
|
||||
$entity_type_id,
|
||||
'views_data'
|
||||
);
|
||||
}
|
||||
catch (PluginNotFound $e) {
|
||||
throw new PluginNotFound($entity_type_id, sprintf(
|
||||
'The "%s" entity type did not specify views_data handler class.',
|
||||
$entity_type->getLabel()
|
||||
));
|
||||
}
|
||||
|
||||
$field_data_table = $views_data->getViewsTableForEntityType($entity_type);
|
||||
|
||||
if (!empty($field_data_table)) {
|
||||
$key = $entity_type_id . '_translation';
|
||||
$target_key = $key . '_target';
|
||||
$group = t('@entity_label translation', [
|
||||
'@entity_label' => $entity_type->getLabel(),
|
||||
]);
|
||||
|
||||
$translations_table =& $data[$key];
|
||||
$translations_table_target =& $data[$target_key];
|
||||
|
||||
$pk = $entity_type->getKey('id');
|
||||
|
||||
$translations_table['table'] = [
|
||||
'group' => $group,
|
||||
'entity type' => $entity_type_id,
|
||||
'join' => [
|
||||
$field_data_table => [
|
||||
'join_id' => 'translation_views_language_join',
|
||||
'type' => 'LEFT',
|
||||
'left_field' => $pk,
|
||||
'field' => $pk,
|
||||
'table' => $field_data_table,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$translations_table += FieldDefinitions::buildStatusField();
|
||||
$translations_table += FieldDefinitions::buildTargetLanguageField();
|
||||
$translations_table += FieldDefinitions::buildOpLinksField();
|
||||
$translations_table += FieldDefinitions::buildCountField();
|
||||
|
||||
$translations_table_target['table'] = [
|
||||
'group' => $group,
|
||||
'join' => [
|
||||
$field_data_table => [
|
||||
'type' => 'LEFT',
|
||||
'left_field' => $pk,
|
||||
'field' => $pk,
|
||||
'table' => $field_data_table,
|
||||
'extra' => [
|
||||
[
|
||||
'field' => 'langcode',
|
||||
'value' => '***TRANSLATION_VIEWS_TARGET_LANG***',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$translations_table_target += FieldDefinitions::buildOutdatedField(
|
||||
$translations_table['content_translation_outdated']
|
||||
);
|
||||
$translations_table_target += FieldDefinitions::buildSourceField(
|
||||
$translations_table['content_translation_source']
|
||||
);
|
||||
$translations_table_target += FieldDefinitions::buildDefaultLangcodeField(
|
||||
$translations_table['default_langcode']
|
||||
);
|
||||
$translations_table_target += FieldDefinitions::buildChangedField(
|
||||
$translations_table['changed']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide views runtime hooks for translation_views.module.
|
||||
*
|
||||
* Provides views target language substitution.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
||||
/**
|
||||
* Implements hook_views_query_substitutions().
|
||||
*/
|
||||
function translation_views_views_query_substitutions(ViewExecutable $view) {
|
||||
$inputs = $view->getExposedInput();
|
||||
$langcodes = array_keys(\Drupal::languageManager()->getLanguages(
|
||||
LanguageInterface::STATE_CONFIGURABLE
|
||||
));
|
||||
|
||||
if (isset($inputs['translation_target_language'])
|
||||
&& in_array($inputs['translation_target_language'], $langcodes)
|
||||
) {
|
||||
$langcode = $inputs['translation_target_language'];
|
||||
}
|
||||
else {
|
||||
$langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
|
||||
}
|
||||
|
||||
$substitutions = [
|
||||
'***TRANSLATION_VIEWS_TARGET_LANG***' => $langcode,
|
||||
];
|
||||
|
||||
return $substitutions;
|
||||
}
|
||||
Reference in New Issue
Block a user