i18n-edit 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f8e5bc9c7fcb94a66e6d124ffb80516d86af55b
4
+ data.tar.gz: b7538633d732833852c1451191bca562d13cc17d
5
+ SHA512:
6
+ metadata.gz: c1f99497c941ba9d633b2c1a635db051cbc8a95d629e05d5905ebd226e0f04674cf9a0d046f4c5c4e99105caf31471e812f6d5bbef8e52fc544799adb56f0495
7
+ data.tar.gz: 995a4afe0e191d255df29e161131735f6851b4611d45331492d7d0370b4479719986426fd5e4ba3c572795102c7e8a7c8d973084780e9d051d97ddf0d2849e03
data/AFFERO_GPL3.txt ADDED
@@ -0,0 +1,244 @@
1
+ This software is copyright (C) 2017 Equipment Unit LLC, All rights reserved.
2
+
3
+ SIMPLE TESTING GRANT
4
+
5
+ You may combine this software with your own software, for the purpose of your testing
6
+ and development of that software. This grant does not apply to other purposes, for
7
+ example the integration of this software into a larger product which is distributed to
8
+ others or performed to others as a service.
9
+
10
+ If this grant is insufficient for your needs, you may alternatively apply the terms of
11
+ the GNU AFFERO GPL 3, below, or you may purchase a commercial license from Equipment
12
+ Unit LLC.
13
+
14
+ GNU AFFERO GENERAL PUBLIC LICENSE
15
+
16
+ Version 3, 19 November 2007
17
+
18
+ Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
19
+ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
20
+
21
+ Preamble
22
+
23
+ The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
24
+
25
+ The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
26
+
27
+ 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 them 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.
28
+
29
+ Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
30
+
31
+ A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
32
+
33
+ The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
34
+
35
+ An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
36
+
37
+ The precise terms and conditions for copying, distribution and modification follow.
38
+
39
+ TERMS AND CONDITIONS
40
+
41
+ 0. Definitions.
42
+
43
+ "This License" refers to version 3 of the GNU Affero General Public License.
44
+
45
+ "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
46
+
47
+ "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
48
+
49
+ To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
50
+
51
+ A "covered work" means either the unmodified Program or a work based on the Program.
52
+
53
+ To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
54
+
55
+ To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
56
+
57
+ An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
58
+
59
+ 1. Source Code.
60
+
61
+ The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
62
+
63
+ A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
64
+
65
+ The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
66
+
67
+ The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
68
+
69
+ The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
70
+
71
+ The Corresponding Source for a work in source code form is that same work.
72
+
73
+ 2. Basic Permissions.
74
+
75
+ All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
76
+
77
+ You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
78
+
79
+ Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
80
+
81
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
82
+
83
+ No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
84
+
85
+ When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
86
+
87
+ 4. Conveying Verbatim Copies.
88
+
89
+ You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
90
+
91
+ You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
92
+
93
+ 5. Conveying Modified Source Versions.
94
+
95
+ You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
96
+
97
+ a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
98
+ b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
99
+ c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
100
+ d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
101
+ A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
102
+
103
+ 6. Conveying Non-Source Forms.
104
+
105
+ You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
106
+
107
+ a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
108
+ b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
109
+ c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
110
+ d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
111
+ e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
112
+ A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
113
+
114
+ A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
115
+
116
+ "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
117
+
118
+ If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
119
+
120
+ The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
121
+
122
+ Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
123
+
124
+ 7. Additional Terms.
125
+
126
+ "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
127
+
128
+ When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
129
+
130
+ Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
131
+
132
+ a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
133
+ b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
134
+ c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
135
+ d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
136
+ e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
137
+ f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
138
+ All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
139
+
140
+ If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
141
+
142
+ Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
143
+
144
+ 8. Termination.
145
+
146
+ You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
147
+
148
+ However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
149
+
150
+ Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
151
+
152
+ Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
153
+
154
+ 9. Acceptance Not Required for Having Copies.
155
+
156
+ You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
157
+
158
+ 10. Automatic Licensing of Downstream Recipients.
159
+
160
+ Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
161
+
162
+ An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
163
+
164
+ You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
165
+
166
+ 11. Patents.
167
+
168
+ A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
169
+
170
+ A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
171
+
172
+ Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
173
+
174
+ In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
175
+
176
+ If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
177
+
178
+ If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
179
+
180
+ A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
181
+
182
+ Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
183
+
184
+ 12. No Surrender of Others' Freedom.
185
+
186
+ If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
187
+
188
+ 13. Remote Network Interaction; Use with the GNU General Public License.
189
+
190
+ Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
191
+
192
+ Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
193
+
194
+ 14. Revised Versions of this License.
195
+
196
+ The Free Software Foundation may publish revised and/or new versions of the GNU Affero 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.
197
+
198
+ Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
199
+
200
+ If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
201
+
202
+ Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
203
+
204
+ 15. Disclaimer of Warranty.
205
+
206
+ 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.
207
+
208
+ 16. Limitation of Liability.
209
+
210
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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.
211
+
212
+ 17. Interpretation of Sections 15 and 16.
213
+
214
+ If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
215
+
216
+ END OF TERMS AND CONDITIONS
217
+
218
+ How to Apply These Terms to Your New Programs
219
+
220
+ 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.
221
+
222
+ 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 state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
223
+
224
+ <one line to give the program's name and a brief idea of what it does.>
225
+ Copyright (C) <year> <name of author>
226
+
227
+ This program is free software: you can redistribute it and/or modify
228
+ it under the terms of the GNU Affero General Public License as
229
+ published by the Free Software Foundation, either version 3 of the
230
+ License, or (at your option) any later version.
231
+
232
+ This program is distributed in the hope that it will be useful,
233
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
234
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
235
+ GNU Affero General Public License for more details.
236
+
237
+ You should have received a copy of the GNU Affero General Public License
238
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
239
+ Also add information on how to contact you by electronic and paper mail.
240
+
241
+ If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
242
+
243
+ You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.
244
+
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Declare your gem's dependencies in i18n-edit.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use a debugger
14
+ # gem 'byebug', group: [:development, :test]
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # I18n::Edit
2
+ This in-place editor takes all of the hassle out of managing internationalized text.
3
+ Just click on internationalized text where it usually appears on your live site and
4
+ edit it right there, with no need to know the translation key, working in only one
5
+ window. Right-click on text to see its translation key. Right-click on any HTML node
6
+ to edit its internationalized attributes (like tooltips). Right-click on links and other
7
+ clickable objects to edit their text.
8
+
9
+ ## Usage
10
+ Warning: If you have comments in your locale files, they will be erased as those files
11
+ are edited.
12
+
13
+ Invoke your rails project this way:
14
+
15
+ I18N_EDIT=1 rails s
16
+
17
+ Just click on internationalzed text and edit it, right where it appears. Text is written
18
+ to your locale file when you change the focus to another element, or go to another page.
19
+ Right-click on any internationalized text or any HTML node with internationalized
20
+ attributes to see a menu which allows you to edit them.
21
+
22
+ A browser that implements *contenteditable* and Javascript ES6 is required. Any recent
23
+ version of Chrome or Firefox should do.
24
+
25
+ The javascript console will tell you what key you're editing and when the data is
26
+ written. But you don't really have to look at that to use this tool. Just click on the
27
+ text where it usually appears, and edit!
28
+
29
+ ## Installation
30
+ Add the gem 'i18n-edit' to your Gemfile and run "bundle install".
31
+
32
+ Add this line to your routes in config/routes:
33
+
34
+ i18n_edit_routes
35
+
36
+ In app/views/layouts, add this line within the <head> element of your layout (or
37
+ more than one layout, depending on your project), to include the required Javascript
38
+ file:
39
+
40
+ = i18n_edit_assets
41
+
42
+ ## How It Works
43
+ If I18N_EDIT is not set in the environment, this gem does nothing and should not
44
+ harm your application or its security. When it's set, the magic happens.
45
+
46
+ I18n.translate() is patched to emit a html-safe span containing the editable translation
47
+ text, with the contenteditable attribute set. Javascript catches all of the
48
+ internationalized attributes containing this span, removes it, and places a span
49
+ around the HTML node instead. Javascript is used to catch editing events and requests
50
+ to update the locale text to your rails project. A controller and routes are added to
51
+ handle those requests.
52
+
53
+ Only locale files under the root of your rails project (rather than ones in gems, etc.)
54
+ will be edited. Locale files are replaced using the link-create-write-fsync-rename
55
+ algorithm, which assures that there will always be valid data in your locale files, even
56
+ across a system crash.
57
+
58
+ ## Security
59
+
60
+ Anyone who can access your pages can edit your locale data! So don't run with
61
+ I18N_EDIT=1 set if anyone outside can access your pages. A CSRF token is used,
62
+ so only someone who can read the page will be able to write the locale data.
63
+ The i18n_edit controller will reject everything if I18N_EDIT is not set in the
64
+ environment when you start your rails project.
65
+
66
+
67
+ ## Contributing
68
+
69
+ Write to bruce@perens.com
70
+
71
+
72
+ ## License
73
+ This software is copyright (C) 2017 Equipment Unit LLC, All rights reserved.
74
+
75
+ SIMPLE TESTING GRANT
76
+
77
+ You may combine this software with your own software, for the purpose of your testing
78
+ and development of that software. This grant does not apply to other purposes, for
79
+ example the integration of this software into a larger product which is distributed to
80
+ others or performed to others as a service.
81
+
82
+ If this grant is insufficient for your needs, you may alternatively apply the terms of
83
+ the GNU AFFERO GPL 3, or you may purchase a commercial license from Equipment Unit LLC.
84
+ Write to bruce@perens.com .
85
+
86
+ WARNING: Dynamic linking does not insulate your work from the obligations of either
87
+ license. This was confirmed by the decision on APIs and derivative works by the appeals
88
+ court in Oracle v. Google.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'I18n::Edit'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,15 @@
1
+ This software is copyright (C) 2017 Equipment Unit LLC, All rights reserved.
2
+
3
+ SIMPLE TESTING GRANT
4
+
5
+ You may combine this software with your own software, for the purpose of your testing
6
+ and development of that software. This grant does not apply to other purposes, for
7
+ example the integration of this software into a larger product which is distributed to
8
+ others or performed to others as a service.
9
+
10
+ If this grant is insufficient for your needs, you may alternatively apply the terms of
11
+ the GNU AFFERO GPL 3, or you may purchase a commercial license from Equipment Unit LLC.
12
+
13
+ WARNING: Dynamic linking does not insulate your work from the obligations of either
14
+ license. This was confirmed by the decision on APIs and derivative works by the appeals
15
+ court in Oracle v. Google.
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,350 @@
1
+ 'use strict';
2
+
3
+ class I18n_Edit {
4
+ constructor() {
5
+ // Write the object being edited if the page is unloaded.
6
+ window.addEventListener('beforeunload', this.call_method(this.event_beforeunload));
7
+
8
+ // Remove the i18n_edit span from the document title.
9
+ var match = document.title.match(this.span_pattern());
10
+ if (match) {
11
+ document.title = match[2];
12
+ }
13
+
14
+ // A span of class i18n_edit will be placed around each internationalized text
15
+ // by the Rails code, to handle the editor events. Connect the event handlers.
16
+ var list = document.getElementsByClassName('i18n_edit');
17
+ Array.from(list).forEach(this.call_method(this.connect_editor_span));
18
+
19
+ // The Rails code will place an i18n_edit span around each internationalized
20
+ // attribute of an HTML node. But spans in attributes don't parse.
21
+ // Handle_internationalized_attributes() removes the span from each internationalized
22
+ // attribute and instead places a span around the node.
23
+ list = document.getElementsByTagName('*')
24
+ for (var i = 0; i < list.length; i++ ) {
25
+ this.handle_internationalized_attributes(list, i);
26
+ }
27
+
28
+ // Tell the user that the editor is running.
29
+ console.log("i18n_edit, by Bruce Perens <bruce@perens.com>");
30
+ }
31
+
32
+ // Return a function that calls the named method on this object, passing one argument.
33
+ // Used to install class methods as event handlers, with a correct "this" pointer.
34
+ call_method(func) {
35
+ const object = this;
36
+ return function(arg) { func.call(object, arg); }
37
+ }
38
+
39
+ // A span of class i18n_edit will be placed around each internationalized text
40
+ // by the Rails code, to handle the editor events. Connect the event handlers.
41
+ // If "dismiss" is true, right-click will dismiss the menu rather than create a new
42
+ // one. This is used when connecting up the editable-text span in a context menu.
43
+ connect_editor_span(e, dismiss = false) {
44
+ var context_menu_function = dismiss ? this.event_contextmenu_dismiss : this.event_contextmenu;
45
+ e.addEventListener('contextmenu', this.call_method(context_menu_function));
46
+ e.addEventListener('focus', this.call_method(this.event_focus));
47
+ e.addEventListener('focusout', this.call_method(this.event_focusout));
48
+ e.addEventListener('input', this.call_method(this.event_input));
49
+ // If the parent is a label and has a "for" attribute, remove it.
50
+ // "for" tells the browser to send the focus to the companion input
51
+ // when the label is clicked.
52
+ // While editing the label text, the focus must remain on the label,
53
+ // not be diverted to the input.
54
+ e.parentElement.removeAttribute('for')
55
+ }
56
+
57
+ // When an editor menu is dismissed, this is called on each i18n_edit_menu_parent
58
+ // node in the document (just one, unless one somehow got left around) and destroys
59
+ // it.
60
+ destroy_node(o) {
61
+ o.parentElement.removeChild(o);
62
+ }
63
+
64
+ // An alert is triggered when an editable object is focused and the server isn't
65
+ // running. When the alert is dismissed, the same object gets the focus back and
66
+ // triggers the alert again, in a loop. To break the loop, remove focus from every
67
+ // node in the document.
68
+ do_blur() {
69
+ window.blur();
70
+ var list = document.getElementsByTagName('*')
71
+ for (var i = 0; i < list.length; i++ ) {
72
+ list[i].blur();
73
+ }
74
+ }
75
+
76
+ // Command the Rails code to write the edited text.
77
+ do_update() {
78
+ var s = this.element
79
+ var new_text = s.innerText;
80
+
81
+ new_text = new_text.replace(/(\r\n)|(\\r\\n)|\r|\n|\\r|\\n/g, ' ');
82
+ if (new_text != s.innerText) {
83
+ s.innerText = new_text;
84
+ }
85
+
86
+ if (new_text == this.old_text) {
87
+ return;
88
+ }
89
+
90
+ this.post_form('update', this.event_xhr_succeeded, function(f){
91
+ f.append("key", s.id);
92
+ f.append("text", new_text);
93
+ f.append("old_text", this.old_text);
94
+ f.append("token", this.token);
95
+ });
96
+
97
+ // Search all i18n_edit spans for id = the key, and update them.
98
+ var list = document.querySelectorAll("[id='" + s.id + "']")
99
+ for (var i = 0; i < list.length; i++) {
100
+ var n = list[i];
101
+ if ( n.className == 'i18n_edit' ) {
102
+ n.innerText = new_text;
103
+ }
104
+ }
105
+
106
+ // Search for any i18n_edit_attributes span with attribute_name: key in its
107
+ // data-i18n hash, and update the attribute.
108
+ list = document.getElementsByClassName('i18n_edit_attributes');
109
+ for (var i = 0; i < list.length; i++) {
110
+ var n = list[i];
111
+ var i18n_string = n.getAttribute('data-i18n');
112
+ if (i18n_string) {
113
+ var i18n = JSON.parse(i18n_string);
114
+ for (var key in i18n) {
115
+ if (i18n[key] == s.id) {
116
+ n.firstChild.setAttribute(key, new_text);
117
+ }
118
+ }
119
+ }
120
+ }
121
+
122
+ this.element = null
123
+ this.text = null
124
+ }
125
+
126
+ // If an edit was in progress and the page is being unloaded, write the edit.
127
+ event_beforeunload(e) {
128
+ if ( this.element ) {
129
+ if ( this.element.innerText != this.old_text ) {
130
+ this.do_update();
131
+ }
132
+ }
133
+ }
134
+
135
+ // Here is how to create a context menu from Rails.
136
+ // First, dismiss any menu that is currently being presented by deleting its
137
+ // i18n_edit_menu_parent node from the document.
138
+ // Append a new i18n_edit_menu_parent node to the document to contain the new menu.
139
+ // Post a form to the Rails code asking it to render a context menu with the
140
+ // attributes of the HTML node.
141
+ // When Rails renders the menu, event_show_menu() will add the rendered HTML to
142
+ // the innerHTML of the i18n_edit_menu_parent node.
143
+ event_contextmenu(e) {
144
+ this.event_contextmenu_dismiss(e);
145
+ var container = e.target;
146
+ if (container.className != 'i18n_edit' ) {
147
+ while (container != null && container.parentElement != null && container.className != 'i18n_edit_attributes') {
148
+ container = container.parentElement;
149
+ }
150
+ }
151
+
152
+ // If the text has already been edited and the user calls for the context menu:
153
+ // First, write the old text. Then wait for the XHR success callback to indicate
154
+ // that the rails code has completed the write. Then, arrange for
155
+ // this.event_xhr_succeeded() to call this method again to put up the menu with
156
+ // the new text. Then return, thus allowing the thread to handle
157
+ // this.event_xhr_succeeded().
158
+ if (container.className == 'i18n_edit' && this.element == container) {
159
+ this.do_update();
160
+ this.deferred_event = function() { this.event_contextmenu(e); };
161
+ return;
162
+ }
163
+
164
+ var menu = document.createElement('span');
165
+ menu.setAttribute('class', 'i18n_edit_menu_parent');
166
+ menu.addEventListener('contextmenu', this.call_method(this.event_contextmenu_dismiss));
167
+ document.body.appendChild(menu);
168
+
169
+ var i18n = container.getAttribute('data-i18n') || "{ \"text\": \"" + e.target.id + "\" }";
170
+ this.post_form('menu', this.event_show_menu, function(f){
171
+ f.append("x", e.clientX);
172
+ f.append("y", e.clientY);
173
+ f.append("i18n", i18n);
174
+ f.append("token", container.getAttribute('data-token'));
175
+ });
176
+ }
177
+
178
+ // Dismiss the menu that is currently being presented, if any.
179
+ event_contextmenu_dismiss(e) {
180
+ if (e) {
181
+ e.preventDefault();
182
+ e.stopPropagation();
183
+ }
184
+ var list = document.getElementsByClassName('i18n_edit_menu_parent');
185
+ Array.from(list).forEach(this.call_method(this.destroy_node));
186
+ }
187
+
188
+ // One of our i18n_edit spans got the focus.
189
+ // Set element so that we know what we are editing, and set old_text so that we can
190
+ // check the old text before rewriting it or, when necessary, revert to the old text.
191
+ // Submit a form to the Rails code to check the CSRF token. If the CSRF token is wrong,
192
+ // that usually means that the user re-started the Rails server. Reload the page. That
193
+ // will generally get us a correct CSRF token, and the user can continue.
194
+ // This will also catch if the Rails server isn't running, and complain to the user
195
+ // that it must be running to edit the internationalized text.
196
+ event_focus(e) {
197
+ e.preventDefault();
198
+ e.stopPropagation();
199
+ var s = e.target;
200
+ this.element = s;
201
+ this.token = s.getAttribute('data-token');
202
+ // Deep copy innerText rather than take its reference, just in case the browser
203
+ // edits it in place.
204
+ this.old_text = (' ' + s.innerText).slice(1);
205
+ console.log("Editing " + s.id);
206
+ this.post_form('check_token', this.event_xhr_succeeded, function(f){
207
+ f.append('token', this.token);
208
+ });
209
+ }
210
+
211
+ // One of our i18n_edit spans is losing the focus. Write the edited text, if it has
212
+ // changed.
213
+ event_focusout(e) {
214
+ e.preventDefault();
215
+ e.stopPropagation();
216
+ if ( e.target && e.target == this.element) {
217
+ this.do_update();
218
+ }
219
+ }
220
+
221
+ // Someone's typing at one of our i18n_edit spans. Save which one, so that the
222
+ // page-unload handler knows what was being edited and can write it.
223
+ event_input(e) {
224
+ e.preventDefault();
225
+ e.stopPropagation();
226
+ // Keep this.element up-to-date, so that event_beforeunload() will get the
227
+ // most recent innerText.
228
+ this.element = e.target;
229
+ }
230
+
231
+ // This is called when the Rails code renders a context menu in response to an XHR
232
+ // form. Place the rendered text within the i18n_edit_menu_parent node, and connect
233
+ // event handlers so that the editable text within the menu can be edited.
234
+ //
235
+ // This also:
236
+ // * Handles status 202, which means reload the page, usually after a CSRF token
237
+ // mis-match caused by re-starting Rails.
238
+ // * Presents an alert for any status not otherwise handled.
239
+ event_show_menu(e) {
240
+ var menu_html = e.target.responseText;
241
+ if (e.target.status == 200) {
242
+ var node = document.getElementsByClassName('i18n_edit_menu_parent')[0];
243
+ node.innerHTML = menu_html;
244
+ var list = node.getElementsByClassName('i18n_edit');
245
+ Array.from(list).forEach(this.call_method(this.connect_editor_span), true);
246
+ }
247
+ else {
248
+ this.event_xhr_succeeded(e);
249
+ }
250
+ }
251
+
252
+ // If an XHR request failed, it's because the Rails server isn't running. Complain
253
+ // to the user.
254
+ event_xhr_failed() {
255
+ window.alert("i18n_edit: Your rails project must be running so that it can edit its own locale data.")
256
+ this.do_blur();
257
+ }
258
+
259
+ // Handle XHR requests other than requests for Rails to render a context menu.
260
+ // If status is 200, put the response text on the Javascript console.
261
+ // If status is 202, this indicates a CSRF token mismatch, usually caused by the
262
+ // user re-starting Rails. Reload the page.
263
+ // Any other status indicates a Rails failure, tell the user to see the Rails console.
264
+ event_xhr_succeeded(e) {
265
+ if (e.target.status == 200) {
266
+ var t = e.target.responseText;
267
+ if (t != "OK") {
268
+ console.log(e.target.responseText);
269
+ }
270
+ if (this.deferred_event) {
271
+ this.deferred_event.call(this);
272
+ this.deferred_event = null;
273
+ }
274
+ }
275
+ else if ( e.target.status == 201 ) {
276
+ window.alert(e.target.responseText);
277
+ this.do_blur();
278
+ }
279
+ else if (e.target.status == 202) {
280
+ console.log("i18n_edit: reloading the page: " + e.target.responseText);
281
+ window.location.reload(true);
282
+ }
283
+ else {
284
+ window.alert("Edit failed. Please see the rails diagnostic output.");
285
+ this.do_blur();
286
+ }
287
+ }
288
+
289
+ // Everywhere that I've stuck a span around translated text and that span has ended
290
+ // up in an attribute of an HTML node (where it's invalid), remove the span, and create
291
+ // an i18n_edit_attributes span around the HTML node in its place.
292
+ // This supports multiple internationalized attributes within one HTML node.
293
+ handle_internationalized_attributes(list, index) {
294
+ var n = list[index];
295
+ const id_pattern = "id\\s*=\\s*([^\\s>]+)[\\s>]";
296
+ const token_pattern = "data-token\\s*=\\s*([^\\s>]+)[\\s>]";
297
+
298
+ if ( n.nodeType == Node.ELEMENT_NODE && n.className != 'i18n_edit' && n.className != 'i18n_edit_attributes' ) {
299
+ var i18n = {};
300
+ var token;
301
+ var length = n.attributes.length;
302
+ for (var i = 0; i < length; i++ ) {
303
+ var a = n.attributes[i];
304
+ if (a.specified && a.value != '' && a.name != 'class' && a.name != 'id' && a.name != 'style') {
305
+ var span_match = a.value.match(this.span_pattern());
306
+ if (span_match) {
307
+ a.value = span_match[2]
308
+ var id_match = span_match[1].match(id_pattern);
309
+ i18n[a.name] = id_match[1];
310
+ var token_match = span_match[1].match(token_pattern);
311
+ token = token_match[1];
312
+ }
313
+ }
314
+ }
315
+ if (Object.keys(i18n).length > 0) {
316
+ var container = document.createElement('span');
317
+ container.setAttribute('class', 'i18n_edit_attributes');
318
+ container.setAttribute('data-i18n', JSON.stringify(i18n));
319
+ container.setAttribute('data-token', token);
320
+ n.parentNode.replaceChild(container, n);
321
+ container.appendChild(n);
322
+ container.addEventListener('contextmenu', this.call_method(this.event_contextmenu));
323
+ }
324
+ }
325
+ }
326
+
327
+ // Post a form to Rails using XHR.
328
+ // action is an action to call in the i18n_edit controller.
329
+ // success is the event handler to call when the request succeeds.
330
+ // build_form_data is a function (usually inline) that is passed the form object and
331
+ // creates appropriate form data for the request.
332
+ post_form(action, success_event_handler, build_form_data) {
333
+ var l = window.location
334
+ var url = l.protocol + "//" + l.hostname + (l.port ? ':' + l.port : "") + "/i18n_edit/" + action;
335
+ var x = new XMLHttpRequest();
336
+ var f = new FormData();
337
+ build_form_data.call(this, f);
338
+ x.onload = this.call_method(success_event_handler);
339
+ x.onerror = this.call_method(this.event_xhr_failed);
340
+ x.open('POST', url, true);
341
+ x.send(f)
342
+ }
343
+
344
+ // This pattern is used to match the i18n_edit span created by the Rails code.
345
+ span_pattern() {
346
+ return "^(\\s*<span\\s+[^>]*?class\\s*=\\s*i18n_edit[^>]*>)(.*?)</span>\\s*$";
347
+ }
348
+ };
349
+
350
+ window.addEventListener('load', function() {window.i18n_edit = new I18n_Edit();});
@@ -0,0 +1,16 @@
1
+ .i18n_edit_attributes_menu {
2
+ z-index: 100;
3
+ position: absolute;
4
+ color: black;
5
+ background-color: white;
6
+ border-style: outset;
7
+ border-color: black;
8
+ padding: 0.25em;
9
+ .h_center {
10
+ text-align: center;
11
+ }
12
+ th, td {
13
+ padding-left: 0.5em;
14
+ padding-right: 0.5em;
15
+ }
16
+ }
@@ -0,0 +1,7 @@
1
+ module I18n
2
+ module Edit
3
+ class ApplicationController < ActionController::Base
4
+ protect_from_forgery with: :exception
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,130 @@
1
+ require 'yaml'
2
+ require_dependency 'i18n/edit/application_controller'
3
+
4
+
5
+ module I18n::Edit
6
+ class EditController < ApplicationController
7
+ private
8
+ skip_before_action :verify_authenticity_token
9
+ before_filter :security_check
10
+
11
+ def self.traverse(key_locations, path, prefix, h)
12
+ h.each do |key, value|
13
+ if value.is_a?(String) || value.is_a?(Integer) || value.is_a?(Float) || value.is_a?(TrueClass) || value.is_a?(FalseClass) || value.is_a?(Symbol)
14
+ key_locations[(prefix + key).to_sym] = path
15
+ elsif value.is_a?(Hash) || value.is_a?(Array)
16
+ p = prefix.blank? ? "#{key}." : "#{prefix}#{key}."
17
+ traverse(key_locations, path, p, value)
18
+ else
19
+ raise "Locale value for #{prefix}#{key} is #{value.class.name}"
20
+ end
21
+ end
22
+ end
23
+
24
+ def self.set_key_locations
25
+ key_locations = {}
26
+ I18n.load_path.each do |path|
27
+ next if path.index(Rails.root.to_s) != 0
28
+ f = nil
29
+ begin
30
+ f = File.read(path)
31
+ rescue => exception
32
+ logger.info("#{path}: #{exception.inspect}")
33
+ end
34
+ next unless f
35
+ n = YAML.parse(f).to_ruby
36
+ l = n[I18n.locale.to_s]
37
+ traverse(key_locations, path, '', l) if l
38
+ end
39
+ key_locations
40
+ end
41
+
42
+ KeyLocations = set_key_locations
43
+
44
+ def token_valid?(params, extra_message='')
45
+ if params[:token] != I18n::Edit::Token
46
+ render plain: "Bad security token, reload the page to synchronize. #{extra_message}", status: 202, layout: false
47
+ return false
48
+ else
49
+ return true
50
+ end
51
+ end
52
+
53
+ def write_file(path, key, old_text, text)
54
+ file = File.open(path)
55
+ yaml_data = file.read
56
+ container = parsed_data = YAML.parse(yaml_data).to_ruby
57
+ hashes_path = [I18n.locale.to_s] + key.split('.')
58
+ hashes_path[0...-1].each do |k|
59
+ container = container[k]
60
+ end
61
+ old_text_in_file = container[hashes_path[-1]]
62
+ if old_text != old_text_in_file
63
+ render plain: "The old text in the file is #{old_text_in_file.inspect}, while " \
64
+ "the old text from the browser is #{old_text.inspect}, they don't match. " \
65
+ 'Refusing to write with inconsistent data. ' \
66
+ "Your edit wasn't written.", layout: false, status: 201
67
+ return false;
68
+ end
69
+ container[hashes_path[-1]] = text
70
+ new_file_path = path + '.i18n_edit_new'
71
+ old_file_path = path + '.i18n_edit_old'
72
+ new_file = File.new(new_file_path, File::NOFOLLOW | File::CREAT | File::TRUNC | File::WRONLY, file.stat.mode & 0o777)
73
+ new_file.write(parsed_data.to_yaml)
74
+ new_file.fsync
75
+ begin
76
+ File.unlink(old_file_path)
77
+ rescue
78
+ end
79
+ File.link(path, old_file_path)
80
+ File.rename(new_file_path, path)
81
+ return true;
82
+ end
83
+
84
+ protected
85
+ def security_check
86
+ if ENV['I18N_EDIT'].nil?
87
+ render plain: "I18_EDIT is not set in the environment.", status: 201;
88
+ throw :abort
89
+ elsif !token_valid?(params)
90
+ thorw :abort
91
+ end
92
+ end
93
+
94
+ public
95
+
96
+ def check_token
97
+ render plain: 'OK', status: 200, layout: false
98
+ end
99
+
100
+ def menu
101
+ @style = "top: #{params[:y]}px; left: #{params[:x]}px;"
102
+ @i18n = JSON.parse(params[:i18n])
103
+
104
+ render 'menu', layout: false
105
+ end
106
+
107
+ def update
108
+ key = params[:key]
109
+ text = params[:text]
110
+ old_text = params[:old_text]
111
+ path = KeyLocations[key.to_sym]
112
+
113
+ if text.gsub(/\s/, '').blank?
114
+ render plain: "Erasing the entire locale text isn't allowed.", layout: false, status: 202
115
+ return
116
+ end
117
+
118
+ if path.nil?
119
+ render plain: "No locale file in your project for #{key}, your edit was not written.", layout: false, status: 201
120
+ return
121
+ end
122
+
123
+ return if !write_file(path, key, old_text, text)
124
+
125
+ message = "Wrote #{path} for #{key}"
126
+ logger.info(message)
127
+ render plain: message, layout: false, status: 200
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,14 @@
1
+ module I18n
2
+ module Edit
3
+ module ApplicationHelper
4
+ def i18n_edit_assets
5
+ if ENV['I18N_EDIT'].nil?
6
+ return ''
7
+ else
8
+ return javascript_include_tag('i18n/edit/application.js') + \
9
+ stylesheet_link_tag('i18n/edit/i18n_edit.css')
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ .i18n_edit_attributes_menu[style=@style]
2
+ table
3
+ tr
4
+ th
5
+ | Attribute
6
+ th
7
+ | Editable Text
8
+ th
9
+ | Translation Key
10
+ - @i18n.each do |key, value|
11
+ tr
12
+ td
13
+ = key
14
+ td
15
+ = t(value)
16
+ td
17
+ = value
18
+
19
+ .h_center
20
+ button[type='button' class='i18n_edit_dismiss_button' onclick='i18n_edit.event_contextmenu_dismiss(null);']
21
+ | Dismiss
@@ -0,0 +1,6 @@
1
+ module ActionController
2
+ class Base
3
+ helper I18n::Edit::ApplicationHelper
4
+ end
5
+ end
6
+
@@ -0,0 +1,8 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ def i18n_edit_routes
4
+ mount I18n::Edit::Engine => '/'
5
+ end
6
+ end
7
+ end
8
+
@@ -0,0 +1 @@
1
+ Rails.application.config.assets.precompile += %w( i18n/edit/i18n_edit.css )
@@ -0,0 +1,15 @@
1
+ # Wrap a span around every translated text, which provides a handle for my editor.
2
+ # This will put spans in attributes of HTML nodes where they aren't valid. My
3
+ # javascript then comes along and removes those, placing a span around the node that
4
+ # contains them instead.
5
+ module ::I18n::Backend::Base
6
+ alias_method :orig_translate, :translate
7
+ def translate(language, key, options)
8
+ value = orig_translate(language, key, options)
9
+ if ENV['I18N_EDIT']
10
+ return "<span class=i18n_edit contenteditable=true data-token=#{::I18n::Edit::Token} id=#{key.to_s}>#{value}</span>".html_safe
11
+ else
12
+ return value
13
+ end
14
+ end
15
+ end
@@ -0,0 +1 @@
1
+ require 'i18n/edit'
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ I18n::Edit::Engine.routes.draw do
2
+ post '/i18n_edit/update' => 'edit#update'
3
+ post '/i18n_edit/check_token' => 'edit#check_token'
4
+ post '/i18n_edit/menu' => 'edit#menu'
5
+ post '/i18n_edit/enable' => 'edit#enable'
6
+ get '/i18n_edit/enable' => 'edit#enable'
7
+ end
data/i18n-edit.gemspec ADDED
@@ -0,0 +1,51 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "i18n/edit/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "i18n-edit"
9
+ s.version = I18n::Edit::VERSION
10
+ s.authors = ["Bruce Perens"]
11
+ s.email = ["bruce@perens.com"]
12
+ s.homepage = "http://perens.com/i18n-edit/"
13
+ s.summary = "In-place editor of internationalized text (locale data)."
14
+ s.description = "Take the hassle out of managing internationized text! " \
15
+ "This in-place editor allows you to click on the text where it " \
16
+ "appears in your view in a live application, and edit it right " \
17
+ "there. No need to know the translation key, no multiple windows."
18
+ s.license = "AGPL-3.0"
19
+
20
+ s.files = Dir[
21
+ 'Gemfile',
22
+ 'Rakefile',
23
+ 'app/controllers/i18n/edit/application_controller.rb',
24
+ 'app/controllers/i18n/edit/edit_controller.rb',
25
+ 'app/assets/javascripts/i18n/edit/application.js',
26
+ 'app/assets/javascripts/i18n/edit/i18n_edit.js',
27
+ 'app/assets/stylesheets/i18n/edit/i18n_edit.scss',
28
+ 'app/helpers/i18n/edit/application_helper.rb',
29
+ 'app/views/i18n/edit/edit/menu.html.slim',
30
+ 'config/routes.rb',
31
+ 'config/initializers/i18n_edit.rb',
32
+ 'config/initializers/action_controller.rb',
33
+ 'config/initializers/action_dispatch.rb',
34
+ 'config/initializers/i18n_backend_base.rb',
35
+ 'config/initializers/assets.rb',
36
+ 'lib/i18n/edit.rb',
37
+ 'lib/i18n/edit/version.rb',
38
+ 'lib/i18n/edit/engine.rb',
39
+ 'i18n-edit.gemspec',
40
+ 'README.md',
41
+ 'SIMPLE_TESTING_GRANT.txt',
42
+ 'AFFERO_GPL3.txt',
43
+ ]
44
+
45
+ s.add_runtime_dependency 'sysrandom', '~> 1'
46
+
47
+ # Dependency on a semantic version is too coarse to work well with something as large
48
+ # as rails.
49
+ s.add_runtime_dependency 'rails', '> 3'
50
+ # s.add_runtime_dependency 'slim-template', '~> 1'
51
+ end
@@ -0,0 +1,7 @@
1
+ module I18n
2
+ module Edit
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace I18n::Edit
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module I18n
2
+ module Edit
3
+ VERSION = '0.9.0'
4
+ end
5
+ end
data/lib/i18n/edit.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'i18n/edit/engine'
2
+ require 'sysrandom'
3
+
4
+ module I18n
5
+ module Edit
6
+ Token = ::Sysrandom.random_number(1<<63).to_s(36)
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n-edit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Bruce Perens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sysrandom
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ description: Take the hassle out of managing internationized text! This in-place editor
42
+ allows you to click on the text where it appears in your view in a live application,
43
+ and edit it right there. No need to know the translation key, no multiple windows.
44
+ email:
45
+ - bruce@perens.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - AFFERO_GPL3.txt
51
+ - Gemfile
52
+ - README.md
53
+ - Rakefile
54
+ - SIMPLE_TESTING_GRANT.txt
55
+ - app/assets/javascripts/i18n/edit/application.js
56
+ - app/assets/javascripts/i18n/edit/i18n_edit.js
57
+ - app/assets/stylesheets/i18n/edit/i18n_edit.scss
58
+ - app/controllers/i18n/edit/application_controller.rb
59
+ - app/controllers/i18n/edit/edit_controller.rb
60
+ - app/helpers/i18n/edit/application_helper.rb
61
+ - app/views/i18n/edit/edit/menu.html.slim
62
+ - config/initializers/action_controller.rb
63
+ - config/initializers/action_dispatch.rb
64
+ - config/initializers/assets.rb
65
+ - config/initializers/i18n_backend_base.rb
66
+ - config/initializers/i18n_edit.rb
67
+ - config/routes.rb
68
+ - i18n-edit.gemspec
69
+ - lib/i18n/edit.rb
70
+ - lib/i18n/edit/engine.rb
71
+ - lib/i18n/edit/version.rb
72
+ homepage: http://perens.com/i18n-edit/
73
+ licenses:
74
+ - AGPL-3.0
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.6.8
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: In-place editor of internationalized text (locale data).
96
+ test_files: []