diff --git a/assets/Noto_Sans_JP/NotoSansJP-Regular.ttf b/assets/Noto_Sans_JP/NotoSansJP-Regular.ttf new file mode 100644 index 0000000..1583096 Binary files /dev/null and b/assets/Noto_Sans_JP/NotoSansJP-Regular.ttf differ diff --git a/assets/Noto_Sans_JP/NotoSansJP-Thin.ttf b/assets/Noto_Sans_JP/NotoSansJP-Thin.ttf new file mode 100644 index 0000000..a97b876 Binary files /dev/null and b/assets/Noto_Sans_JP/NotoSansJP-Thin.ttf differ diff --git a/assets/Noto_Sans_JP/OFL.txt b/assets/Noto_Sans_JP/OFL.txt new file mode 100644 index 0000000..7deea55 --- /dev/null +++ b/assets/Noto_Sans_JP/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source' + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/assets/Noto_Sans_JP/README.txt b/assets/Noto_Sans_JP/README.txt new file mode 100644 index 0000000..5353e2e --- /dev/null +++ b/assets/Noto_Sans_JP/README.txt @@ -0,0 +1,71 @@ +Noto Sans JP Variable Font +========================== + +This download contains Noto Sans JP as both a variable font and static fonts. + +Noto Sans JP is a variable font with this axis: + wght + +This means all the styles are contained in a single file: + NotoSansJP-VariableFont_wght.ttf + +If your app fully supports variable fonts, you can now pick intermediate styles +that aren’t available as static fonts. Not all apps support variable fonts, and +in those cases you can use the static font files for Noto Sans JP: + static/NotoSansJP-Thin.ttf + static/NotoSansJP-ExtraLight.ttf + static/NotoSansJP-Light.ttf + static/NotoSansJP-Regular.ttf + static/NotoSansJP-Medium.ttf + static/NotoSansJP-SemiBold.ttf + static/NotoSansJP-Bold.ttf + static/NotoSansJP-ExtraBold.ttf + static/NotoSansJP-Black.ttf + +Get started +----------- + +1. Install the font files you want to use + +2. Use your app's font picker to view the font family and all the +available styles + +Learn more about variable fonts +------------------------------- + + https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts + https://variablefonts.typenetwork.com + https://medium.com/variable-fonts + +In desktop apps + + https://theblog.adobe.com/can-variable-fonts-illustrator-cc + https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts + +Online + + https://developers.google.com/fonts/docs/getting_started + https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide + https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts + +Installing fonts + + MacOS: https://support.apple.com/en-us/HT201749 + Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux + Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows + +Android Apps + + https://developers.google.com/fonts/docs/android + https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts + +License +------- +Please read the full license text (OFL.txt) to understand the permissions, +restrictions and requirements for usage, redistribution, and modification. + +You can use them in your products & projects – print or digital, +commercial or otherwise. + +This isn't legal advice, please consider consulting a lawyer and see the full +license for all details. diff --git a/assets/licenses/libintl.txt b/assets/licenses/libintl.txt new file mode 100644 index 0000000..c2c87d6 --- /dev/null +++ b/assets/licenses/libintl.txt @@ -0,0 +1,516 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 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. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations +below. + + When we speak of free software, we are referring to freedom of use, +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 and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. +^L + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it +becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. +^L + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. +^L + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. +^L + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. +^L + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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 with +this License. +^L + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. +^L + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS +^L + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms +of the ordinary General Public License). + + To apply these terms, attach the following notices to the library. +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. + + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; 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. + +You should also get your employer (if you work as a programmer) or +your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James +Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/assets/translation/messages.pot b/assets/translation/messages.pot new file mode 100644 index 0000000..d8a4be9 --- /dev/null +++ b/assets/translation/messages.pot @@ -0,0 +1,528 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Neko Player\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-24 22:50-0700\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.3.2\n" +"X-Poedit-KeywordsList: _TR;_TRS;_TRIS:2;_TRI:2;_TR_CTX:1c,2;_TRS_CTX:1c,2;_TRIS_CTX:2c,3;_TRI_CTX:2c,3\n" +"X-Poedit-Basepath: ../..\n" +"X-Poedit-SearchPath-0: theme.cpp\n" +"X-Poedit-SearchPath-1: main.cpp\n" + +#: main.cpp:226 +msgctxt "File dialog title" +msgid "Open..." +msgstr "" + +#: main.cpp:227 +msgctxt "File dialog filter name" +msgid "Audio files" +msgstr "" + +#: main.cpp:350 +msgctxt "Main menu" +msgid "File" +msgstr "" + +#: main.cpp:351 +msgctxt "Main menu > File" +msgid "Open" +msgstr "" + +#: main.cpp:354 +msgctxt "Main menu > File" +msgid "Quit" +msgstr "" + +#: main.cpp:359 +msgctxt "Main menu" +msgid "Edit" +msgstr "" + +#: main.cpp:360 +msgctxt "Main menu > Edit" +msgid "Preferences..." +msgstr "" + +#: main.cpp:366 +msgctxt "Main menu (in debug builds)" +msgid "Debug" +msgstr "" + +#: main.cpp:367 +msgctxt "Main menu > Debug" +msgid "Show ImGui Demo Window" +msgstr "" + +#: main.cpp:373 +msgctxt "Main menu" +msgid "Help" +msgstr "" + +#: main.cpp:374 +msgctxt "Main menu > Help" +msgid "About" +msgstr "" + +#: main.cpp:382 +msgctxt "Main window title" +msgid "Player" +msgstr "" + +#: main.cpp:411 +#, c-format +msgctxt "Playback controls > slider" +msgid "Speed: %.2fx" +msgstr "" + +#: main.cpp:415 +#, c-format +msgctxt "Playback controls > slider" +msgid "Tempo: %.2fx" +msgstr "" + +#: main.cpp:419 +#, c-format +msgctxt "Playback controls > slider" +msgid "Pitch: %.2fx" +msgstr "" + +#: main.cpp:427 +msgctxt "Window title, window opened by menu item" +msgid "Preferences..." +msgstr "" + +#: main.cpp:429 +msgctxt "Preference > VSync checkbox" +msgid "Enable VSync" +msgstr "" + +#: main.cpp:434 +#, c-format +msgctxt "Preferences > Framerate slider" +msgid "Max framerate without VSync: %d" +msgstr "" + +#: main.cpp:435 +msgctxt "Preference > Related non-preference button" +msgid "Theme Editor" +msgstr "" + +#: main.cpp:439 +msgctxt "Preference > Theme selector > Filter label" +msgid "Filter:" +msgstr "" + +#: main.cpp:442 +msgctxt "Preferences > Theme selector > Selector label" +msgid "Select a theme..." +msgstr "" + +#: main.cpp:478 +#, c-format +msgctxt "Preference > Accent hue slider, range 0-360 from HSV algorithm hue component" +msgid "Accent color hue: %.0f°" +msgstr "" + +#: main.cpp:486 +msgctxt "Window title, window opened by menu item" +msgid "About and Licenses" +msgstr "" + +#: main.cpp:488 +msgctxt "Application name - Japanese word should remain Japanese and stay the same when translating for stylistic purposes." +msgid "ねこ Player" +msgstr "" + +#: main.cpp:492 +msgctxt "Application name - Japanese word should be converted to the translated language's characters. Use an empty string to disable for Japanese." +msgid "(Neko Player)" +msgstr "" + +#: main.cpp:497 +msgctxt "Prefix to the version string in the about window" +msgid "Version " +msgstr "" + +#: main.cpp:497 +msgctxt "Suffix to the version string in the about window, if needed" +msgid "" +msgstr "" + +#: main.cpp:503 +msgctxt "Library name" +msgid "SDL Mixer X" +msgstr "" + +#: main.cpp:504 +msgctxt "Library name" +msgid "JsonCpp" +msgstr "" + +#: main.cpp:505 +msgctxt "Library name" +msgid "SoundTouch" +msgstr "" + +#: main.cpp:506 +msgctxt "Library name" +msgid "libintl" +msgstr "" + +#: main.cpp:507 +msgctxt "Library name" +msgid "Dear ImGui" +msgstr "" + +#: main.cpp:508 +msgctxt "Library name" +msgid "imgui-filebrowser" +msgstr "" + +#: main.cpp:510 +msgctxt "Library name" +msgid "libportal" +msgstr "" + +#: main.cpp:512 +msgctxt "Library name" +msgid "Noto Sans" +msgstr "" + +#: main.cpp:513 +msgctxt "Library name" +msgid "Fork Awesome" +msgstr "" + +#: main.cpp:514 +msgctxt "Library name" +msgid "IconFontCppHeaders" +msgstr "" + +#: main.cpp:539 +msgctxt "Project selector label." +msgid "Project" +msgstr "" + +#: main.cpp:554 +msgctxt "License viewer label" +msgid "License" +msgstr "" + +#: main.cpp:557 +#, c-format +msgctxt "License viewer > information above license - string 1: selected project, string 2: SPDX license identifier" +msgid "%s: %s" +msgstr "" + +#: theme.cpp:36 +msgctxt "Window title" +msgid "Theme Editor" +msgstr "" + +#: theme.cpp:40 +msgctxt "Theme Editor > preset button" +msgid "Create light" +msgstr "" + +#: theme.cpp:49 +msgctxt "Theme Editor > preset button" +msgid "Create dark" +msgstr "" + +#: theme.cpp:57 +msgctxt "Theme Editor > import button. Opens the theme import file dialog" +msgid "Import..." +msgstr "" + +#: theme.cpp:58 +msgctxt "Theme Editor file dialog title" +msgid "Import theme..." +msgstr "" + +#: theme.cpp:59 theme.cpp:73 +msgctxt "Theme Editor file dialog filter name" +msgid "Theme JSON files" +msgstr "" + +#: theme.cpp:71 +msgctxt "Theme Editor > export button. Opens the theme export file dialog" +msgid "Export..." +msgstr "" + +#: theme.cpp:72 +msgctxt "Theme Editor file dialog title" +msgid "Export theme..." +msgstr "" + +#: theme.cpp:95 +msgctxt "Theme Editor > button. Reverts to saved file." +msgid "Revert" +msgstr "" + +#: theme.cpp:104 +msgctxt "Theme Editor > button. Saves the theme to it's current location. Not shown when it doesn't already have one." +msgid "Save" +msgstr "" + +#: theme.cpp:108 +msgctxt "Theme Editor > button. Opens the theme loading dialog for themes created or imported by the user." +msgid "Load..." +msgstr "" + +#: theme.cpp:112 +msgctxt "Theme Editor > button. Opens the theme saving dialog for themes created or imported by the user." +msgid "Save as..." +msgstr "" + +#: theme.cpp:117 +msgctxt "Theme Editor > slider. Simplified frame rounding." +msgid "Frame Rounding" +msgstr "" + +#: theme.cpp:119 +msgctxt "Theme Editor > checkbox" +msgid "Window Border" +msgstr "" + +#: theme.cpp:121 +msgctxt "Theme Editor > checkbox" +msgid "Frame Border" +msgstr "" + +#: theme.cpp:123 +msgctxt "Theme Editor > checkbox" +msgid "Popup Border" +msgstr "" + +#: theme.cpp:129 +msgctxt "Theme Editor > Tab label" +msgid "Sizes" +msgstr "" + +#: theme.cpp:131 +msgctxt "Theme Editor > Sizes > Section label" +msgid "Sizing" +msgstr "" + +#: theme.cpp:132 +msgctxt "Theme Editor > Sizes > Sizing > label of XY sliders" +msgid "Window Padding" +msgstr "" + +#: theme.cpp:133 +msgctxt "Theme Editor > Sizes > Sizing > label of XY sliders" +msgid "Frame Padding" +msgstr "" + +#: theme.cpp:134 +msgctxt "Theme Editor > Sizes > Sizing > label of XY sliders" +msgid "Cell Padding" +msgstr "" + +#: theme.cpp:135 +msgctxt "Theme Editor > Sizes > Sizing > label of XY sliders" +msgid "Item Spacing" +msgstr "" + +#: theme.cpp:136 +msgctxt "Theme Editor > Sizes > Sizing > label of XY sliders" +msgid "Inner Item Spacing" +msgstr "" + +#: theme.cpp:139 +msgctxt "Theme Editor > Sizes > Sizing > slider label" +msgid "Scrollbar Size" +msgstr "" + +#: theme.cpp:140 +msgctxt "Theme Editor > Sizes > Sizing > slider label" +msgid "Minimum Grabber Size" +msgstr "" + +#: theme.cpp:141 +msgctxt "Theme Editor > Sizes > Sizing > label of XY sliders" +msgid "Separator Text Padding" +msgstr "" + +#: theme.cpp:143 +msgctxt "Theme Editor > Sizes > Section label" +msgid "Borders" +msgstr "" + +#: theme.cpp:144 +msgctxt "Theme Editor > Sizes > Borders > slider label" +msgid "Window Border Size" +msgstr "" + +#: theme.cpp:145 +msgctxt "Theme Editor > Sizes > Borders > slider label" +msgid "Child Border Size" +msgstr "" + +#: theme.cpp:146 +msgctxt "Theme Editor > Sizes > Borders > slider label" +msgid "Popup Border Size" +msgstr "" + +#: theme.cpp:147 +msgctxt "Theme Editor > Sizes > Borders > slider label" +msgid "Frame Border Size" +msgstr "" + +#: theme.cpp:148 +msgctxt "Theme Editor > Sizes > Borders > slider label" +msgid "Tab Border Size" +msgstr "" + +#: theme.cpp:149 +msgctxt "Theme Editor > Sizes > Borders > slider label" +msgid "Separator Text Border Size" +msgstr "" + +#: theme.cpp:151 +msgctxt "Theme Editor > Sizes > Section label" +msgid "Rounding" +msgstr "" + +#: theme.cpp:152 +msgctxt "Theme Editor > Sizes > Rounding > slider label" +msgid "Window Rounding" +msgstr "" + +#: theme.cpp:153 +msgctxt "Theme Editor > Sizes > Rounding > slider label" +msgid "Child Rounding" +msgstr "" + +#: theme.cpp:154 +msgctxt "Theme Editor > Sizes > Rounding > slider label" +msgid "Frame Rounding" +msgstr "" + +#: theme.cpp:155 +msgctxt "Theme Editor > Sizes > Rounding > slider label" +msgid "Popup Rounding" +msgstr "" + +#: theme.cpp:156 +msgctxt "Theme Editor > Sizes > Rounding > slider label" +msgid "Scrollbar Rounding" +msgstr "" + +#: theme.cpp:157 +msgctxt "Theme Editor > Sizes > Rounding > slider label" +msgid "Grabber Rounding" +msgstr "" + +#: theme.cpp:158 +msgctxt "Theme Editor > Sizes > Rounding > slider label" +msgid "Tab Rounding" +msgstr "" + +#: theme.cpp:163 +msgctxt "Theme Editor > Tab label" +msgid "Colors" +msgstr "" + +#: theme.cpp:167 +msgctxt "Theme Editor > Colors > text filter" +msgid "Filter colors" +msgstr "" + +#: theme.cpp:170 +msgctxt "Theme Editor > Colors > preview settings radio button" +msgid "Opaque" +msgstr "" + +#: theme.cpp:171 +msgctxt "Theme Editor > Colors > preview settings radio button" +msgid "Alpha" +msgstr "" + +#: theme.cpp:172 +msgctxt "Theme Editor > Colors > preview settings radio button" +msgid "Both" +msgstr "" + +#: theme.cpp:183 +msgctxt "Theme Editor > Colors > (Any color) > recoloring checkbox" +msgid "Match hue preference" +msgstr "" + +#: theme.cpp:220 theme.cpp:223 +msgctxt "Theme Editor > Custom modal dialog title" +msgid "Load..." +msgstr "" + +#: theme.cpp:226 +msgctxt "Theme Editor > Load dialog > Theme selector > filter label" +msgid "Filter:" +msgstr "" + +#: theme.cpp:229 +msgctxt "Theme Editor > Load dialog > Theme selector > label" +msgid "Available themes..." +msgstr "" + +#: theme.cpp:244 +msgctxt "Theme Editor > Load dialog > Load button" +msgid "Load" +msgstr "" + +#: theme.cpp:256 +msgctxt "Theme Editor > Load dialog > Cancel button" +msgid "Cancel" +msgstr "" + +#: theme.cpp:265 theme.cpp:268 +msgctxt "Theme Editor > Custom modal dialog title" +msgid "Save as..." +msgstr "" + +#: theme.cpp:271 +msgctxt "Theme Editor > Save as dialog > Theme selector > filter label" +msgid "Filter:" +msgstr "" + +#: theme.cpp:274 +msgctxt "Theme Editor > Save as dialog > Theme selector > label" +msgid "Available themes..." +msgstr "" + +#: theme.cpp:290 +msgctxt "Theme Editor > Save as dialog > Theme name input label" +msgid "Theme name: " +msgstr "" + +#: theme.cpp:291 +msgctxt "Theme Editor > Save as dialog > Save button" +msgid "Save" +msgstr "" + +#: theme.cpp:302 +msgctxt "Theme Editor > Save as dialog > Cancel button" +msgid "Cancel" +msgstr "" + +#: theme.cpp:451 +msgctxt "Theme default strings > name" +msgid "A theme" +msgstr "" + +#: theme.cpp:452 +msgctxt "Theme default strings > description" +msgid "(No description)" +msgstr "" diff --git a/assets/update-assets.sh b/assets/update-assets.sh index 3efedb3..878d15b 100755 --- a/assets/update-assets.sh +++ b/assets/update-assets.sh @@ -8,18 +8,23 @@ add_basic() { ASSETS+=($2.h) ./btcc -nocompress $1 $2 > $2.h } -add_font() { +add_base85() { ASSETS+=($2.h) ./btcc -base85 $1 $2 > $2.h } $CXX ../imgui/misc/fonts/binary_to_compressed_c.cpp -o btcc -add_font forkawesome-webfont.ttf forkawesome +add_base85 forkawesome-webfont.ttf forkawesome for i in Noto_Sans/*.ttf; do FONT="$(echo -n "$i" | sed 's/^.*\///g' | sed 's/.ttf$//' | tr '[:upper:]' '[:lower:]' | sed 's/-/_/g')" - add_font "$i" "$FONT" + add_base85 "$i" "$FONT" done -add_basic 'icon.png' 'icon' +for i in Noto_Sans_JP/*.ttf; do + FONT="$(echo -n "$i" | sed 's/^.*\///g' | sed 's/.ttf$//' | tr '[:upper:]' '[:lower:]' | sed 's/-/_/g')" + add_base85 "$i" "$FONT" +done +add_base85 'icon.png' 'icon' add_basic 'Noto_Sans/OFL.txt' 'notosans_license' +add_basic 'Noto_Sans_JP/OFL.txt' 'notosansjp_license' add_basic '../LICENSE' 'nekoplayer_license' add_basic '../subprojects/jsoncpp/LICENSE' 'jsoncpp_license' add_basic '../subprojects/SDL-Mixer-X/COPYING.txt' 'sdl_mixer_x_license' @@ -28,6 +33,7 @@ add_basic '../imgui/LICENSE.txt' 'imgui_license' add_basic 'licenses/SoundTouch.txt' 'soundtouch_license' add_basic 'licenses/libportal.txt' 'libportal_license' add_basic 'licenses/ForkAwesome.txt' 'forkawesome_license' +add_basic 'licenses/libintl.txt' 'libintl_license' add_basic '../IconFontCppHeaders/licence.txt' 'icnfntcpphdrs_license' echo '#pragma once' > 'assets.h' for i in "${ASSETS[@]}"; do diff --git a/base85.cpp b/base85.cpp new file mode 100644 index 0000000..01edb97 --- /dev/null +++ b/base85.cpp @@ -0,0 +1,23 @@ +#include "base85.h" +using std::vector; +// Functions modified from Dear ImGui and renamed to avoid collisions. +static unsigned int DecodeBase85Byte(char c) { + return c >= '\\' ? c-36 : c-35; +} +vector DecodeBase85(const char *src) { + vector dst_vec; + dst_vec.reserve((strlen(src) / 5) * 4); + unsigned char *dst = dst_vec.data(); + size_t dst_size = 0; + while (*src) + { + dst_vec.resize(dst_size); + unsigned int tmp = DecodeBase85Byte(src[0]) + 85 * (DecodeBase85Byte(src[1]) + 85 * (DecodeBase85Byte(src[2]) + 85 * (DecodeBase85Byte(src[3]) + 85 * DecodeBase85Byte(src[4])))); + dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness. + src += 5; + dst = dst_vec.data() + dst_size; + dst_size += 4; + } + dst_vec.resize(dst_size); + return dst_vec; +} \ No newline at end of file diff --git a/base85.h b/base85.h new file mode 100644 index 0000000..f88ec62 --- /dev/null +++ b/base85.h @@ -0,0 +1,10 @@ +#pragma once +#include +#include +#include +// Modified from Dear ImGui +std::vector DecodeBase85(const char *src); +// May not be needed now, but could be useful in the future. +static inline std::vector DecodeBase85(const std::string src) { + return DecodeBase85(src.c_str()); +} \ No newline at end of file diff --git a/config.h.in b/config.h.in index 88f52e8..d49cc44 100644 --- a/config.h.in +++ b/config.h.in @@ -1,3 +1,4 @@ #pragma once #define TAG "@TAG@" +#define LOCALE_DIR "@LOCALE_DIR@" #mesondefine DEBUG \ No newline at end of file diff --git a/main.cpp b/main.cpp index dd19f59..2166eb9 100644 --- a/main.cpp +++ b/main.cpp @@ -7,6 +7,7 @@ #include "theme.h" #include "assets.h" #include "IconsForkAwesome.h" +#include #include #include #include @@ -25,10 +26,12 @@ #include #endif #include "license.h" +#include "base85.h" static const char* NAME = "Neko Player"; #ifdef __EMSCRIPTEN__ #include "../libs/emscripten/emscripten_mainloop_stub.h" #endif +#include using namespace std::filesystem; using namespace std::numbers; using std::string; @@ -67,35 +70,49 @@ string TimeToString(double time_code, uint8_t min_components = 1) { } return output; } -ImFont *add_font(const char* data, int size = 13) { - ImFont* font; + +struct FontData { + const char* data; + const ImWchar *ranges; +}; + +ImFont *add_font(vector data_vec, int size = 13) { + ImFont* font = nullptr; ImGuiIO& io = ImGui::GetIO(); - { + for (auto data : data_vec) { ImFontConfig font_cfg = ImFontConfig(); font_cfg.SizePixels = size; font_cfg.OversampleH = font_cfg.OversampleV = 1; font_cfg.PixelSnapH = true; if (font_cfg.SizePixels <= 0.0f) font_cfg.SizePixels = 13.0f * 1.0f; + if (font != nullptr) { + font_cfg.DstFont = font; + font_cfg.MergeMode = true; + } //font_cfg.EllipsisChar = (ImWchar)0x0085; //font_cfg.GlyphOffset.y = 1.0f * IM_FLOOR(font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units - const char* ttf_compressed_base85 = data; - const ImWchar* glyph_ranges = io.Fonts->GetGlyphRangesDefault(); - font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges); + const char* ttf_compressed_base85 = data.data; + const ImWchar* glyph_ranges = data.ranges; + auto new_font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges); + if (font == nullptr) font = new_font; + } + { + ImFontConfig config; + config.MergeMode = true; + config.GlyphMinAdvanceX = size; + config.SizePixels = size; + config.DstFont = font; + static const ImWchar icon_ranges[] = { ICON_MIN_FK, ICON_MAX_FK, 0 }; + io.Fonts->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, float(size), &config, icon_ranges); } - ImFontConfig config; - config.MergeMode = true; - config.GlyphMinAdvanceX = size; - config.SizePixels = size; - config.DstFont = font; - static const ImWchar icon_ranges[] = { ICON_MIN_FK, ICON_MAX_FK, 0 }; - io.Fonts->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, float(size), &config, icon_ranges); return font; } // Main code int main(int, char**) { + bindtextdomain("neko_player", LOCALE_DIR); #ifdef PORTALS g_set_application_name("Neko Player"); #endif @@ -156,7 +173,8 @@ int main(int, char**) if (enable_kms) { SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); } - SDL_Surface* icon = IMG_Load_RW(SDL_RWFromConstMem(icon_data, icon_size), 1); + const vector icon_data = DecodeBase85(icon_compressed_data_base85); + SDL_Surface* icon = IMG_Load_RW(SDL_RWFromConstMem(icon_data.data(), icon_data.size()), 1); SDL_SetWindowIcon(window, icon); SDL_GLContext gl_context = SDL_GL_CreateContext(window); SDL_GL_MakeCurrent(window, gl_context); @@ -197,16 +215,16 @@ int main(int, char**) //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesJapanese()); //IM_ASSERT(font != nullptr); - add_font(notosans_regular_compressed_data_base85); - ImFont *title = add_font(notosans_thin_compressed_data_base85, 48); + add_font({FontData {notosans_regular_compressed_data_base85, io.Fonts->GetGlyphRangesDefault()}, FontData {notosansjp_regular_compressed_data_base85, io.Fonts->GetGlyphRangesJapanese()}}); + ImFont *title = add_font({FontData {notosans_thin_compressed_data_base85, io.Fonts->GetGlyphRangesDefault()}, FontData {notosansjp_thin_compressed_data_base85, io.Fonts->GetGlyphRangesJapanese()}}, 48); // Our state bool show_demo_window = false; ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); FileBrowser fileDialog(false, ImGuiFileBrowserFlags_NoTitleBar|ImGuiFileBrowserFlags_NoMove|ImGuiFileBrowserFlags_NoResize); - fileDialog.SetTitle("Open..."); - fileDialog.SetTypeFilters("Audio files", { ".wav", ".ogg", ".mp3", ".qoa", ".flac", ".xm", ".mod"}); + fileDialog.SetTitle(_TR_CTX("File dialog title", "Open...")); + fileDialog.SetTypeFilters(_TR_CTX("File dialog filter name", "Audio files"), { ".wav", ".ogg", ".mp3", ".qoa", ".flac", ".xm", ".mod"}); std::string userdir = std::getenv( #ifdef _WIN32 "UserProfile" @@ -227,6 +245,7 @@ int main(int, char**) bool stopped = true; bool vsync = false; bool about_window = false; + currentLanguage = "osdefault"; int framerate = 60; { Json::Value config; @@ -253,6 +272,9 @@ int main(int, char**) if (config.isMember("framerate")) { framerate = config["framerate"].asUInt(); } + if (config.isMember("lang")) { + currentLanguage = config["lang"].asString(); + } stream.close(); } if (is_empty(Theme::themeDir)) { @@ -325,31 +347,31 @@ int main(int, char**) if (show_demo_window) ImGui::ShowDemoWindow(&show_demo_window); if (ImGui::BeginMainMenuBar()) { - if (ImGui::BeginMenu(ICON_FK_FILE "File")) { - if (ImGui::MenuItem(ICON_FK_FOLDER_OPEN "Open")) { + if (ImGui::BeginMenu(_TRI_CTX(ICON_FK_FILE, "Main menu", "File"))) { + if (ImGui::MenuItem(_TRI_CTX(ICON_FK_FOLDER_OPEN, "Main menu > File", "Open"))) { fileDialog.Open(); } - if (ImGui::MenuItem(ICON_FK_WINDOW_CLOSE "Quit")) { + if (ImGui::MenuItem(_TRI_CTX(ICON_FK_WINDOW_CLOSE, "Main menu > File", "Quit"))) { done = true; } ImGui::EndMenu(); } - if (ImGui::BeginMenu(ICON_FK_SCISSORS "Edit")) { - if (ImGui::MenuItem(ICON_FK_COG "Preferences...")) { + if (ImGui::BeginMenu(_TRI_CTX(ICON_FK_SCISSORS,"Main menu", "Edit"))) { + if (ImGui::MenuItem(_TRI_CTX(ICON_FK_COG, "Main menu > Edit", "Preferences..."))) { prefs_window = true; } ImGui::EndMenu(); } #ifdef DEBUG - if (ImGui::BeginMenu(ICON_FK_COG "Debug")) { - if (ImGui::MenuItem("Show ImGui Demo Window", nullptr, show_demo_window)) { + if (ImGui::BeginMenu(_TRI_CTX(ICON_FK_COG, "Main menu (in debug builds)", "Debug"))) { + if (ImGui::MenuItem(_TR_CTX("Main menu > Debug", "Show ImGui Demo Window"), nullptr, show_demo_window)) { show_demo_window = !show_demo_window; } ImGui::EndMenu(); } #endif - if (ImGui::BeginMenu(ICON_FK_INFO_CIRCLE "Help")) { - if (ImGui::MenuItem(ICON_FK_INFO "About", nullptr, about_window)) { + if (ImGui::BeginMenu(_TRI_CTX(ICON_FK_INFO_CIRCLE, "Main menu", "Help"))) { + if (ImGui::MenuItem(_TRI_CTX(ICON_FK_INFO, "Main menu > Help", "About"), nullptr, about_window)) { about_window = !about_window; } ImGui::EndMenu(); @@ -357,7 +379,7 @@ int main(int, char**) ImGui::EndMainMenuBar(); } ImGui::SetNextWindowDockID(dockid); - ImGui::Begin(ICON_FK_PLAY "Player", nullptr, 0); + ImGui::Begin(_TRI_CTX(ICON_FK_PLAY, "Main window title", "Player"), nullptr, 0); { ImGui::SetCursorPosY(ImGui::GetWindowHeight() - ImGui::GetFrameHeightWithSpacing() - ImGui::GetFrameHeight() - ImGui::GetStyle().WindowPadding.y); if (ImGui::Button(playback->IsPaused() ? ICON_FK_PLAY "##Pause" : ICON_FK_PAUSE "##Pause")) { @@ -386,15 +408,15 @@ int main(int, char**) const float items = 3.0f; const float between_items = items - 1.0f; ImGui::PushItemWidth((ImGui::GetWindowWidth() / items) - (ImGui::GetStyle().ItemSpacing.x / (items / between_items)) - ((ImGui::GetStyle().WindowPadding.x / items) * 2.0f)); - if (ImGui::SliderFloat("##Speed", &playback->speed, 0.25, 4.0, "Speed: %.2fx", ImGuiSliderFlags_Logarithmic)) { + if (ImGui::SliderFloat("##Speed", &playback->speed, 0.25, 4.0, _TR_CTX("Playback controls > slider", "Speed: %.2fx"), ImGuiSliderFlags_Logarithmic)) { playback->Update(); } ImGui::SameLine(); - if (ImGui::SliderFloat("##Tempo", &playback->tempo, 0.25, 4.0, "Tempo: %.2fx", ImGuiSliderFlags_Logarithmic)) { + if (ImGui::SliderFloat("##Tempo", &playback->tempo, 0.25, 4.0, _TR_CTX("Playback controls > slider", "Tempo: %.2fx"), ImGuiSliderFlags_Logarithmic)) { playback->Update(); } ImGui::SameLine(); - if (ImGui::SliderFloat("##Pitch", &playback->pitch, 0.25, 4.0, "Pitch: %.2fx", ImGuiSliderFlags_Logarithmic)) { + if (ImGui::SliderFloat("##Pitch", &playback->pitch, 0.25, 4.0, _TR_CTX("Playback controls > slider", "Pitch: %.2fx"), ImGuiSliderFlags_Logarithmic)) { playback->Update(); } ImGui::PopItemWidth(); @@ -402,26 +424,27 @@ int main(int, char**) ImGui::End(); if (prefs_window) { ImGui::SetNextWindowDockID(dockid); - ImGui::Begin(ICON_FK_COG "Preferences...", &prefs_window); + ImGui::Begin(_TRI_CTX(ICON_FK_COG, "Window title, window opened by menu item", "Preferences..."), &prefs_window); { - if (ImGui::Checkbox("Enable VSync", &vsync)) { + if (ImGui::Checkbox(_TR_CTX("Preference > VSync checkbox", "Enable VSync"), &vsync)) { SDL_GL_SetSwapInterval(vsync ? 1 : 0); } ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::GetWindowWidth() - ImGui::GetCursorPosX() - ImGui::GetStyle().WindowPadding.x); - ImGui::SliderInt("##Framerate", &framerate, 10, 480, "Max framerate without VSync: %d"); - if (ImGui::Button(ICON_FK_MAGIC "Theme Editor", ImVec2(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f), 0))) { + ImGui::SliderInt("##Framerate", &framerate, 10, 480, _TR_CTX("Preferences > Framerate slider", "Max framerate without VSync: %d")); + if (ImGui::Button(_TRI_CTX(ICON_FK_MAGIC, "Preference > Related non-preference button", "Theme Editor"), ImVec2(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f), 0))) { theme_editor = true; } static char filter[1024] = {0}; - ImGui::Text("Filter:"); ImGui::SameLine(); + ImGui::Text(_TR_CTX("Preference > Theme selector > Filter label", "Filter:")); ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::GetWindowWidth() - ImGui::GetCursorPosX() - ImGui::GetStyle().WindowPadding.x); ImGui::InputText("##FilterInput", filter, 1024); - ImGui::Text("Select a theme..."); + ImGui::Text(_TR_CTX("Preferences > Theme selector > Selector label", "Select a theme...")); ImVec2 ChildSize = ImVec2(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f), -ImGui::GetFrameHeightWithSpacing()); if (ImGui::BeginChildFrame(ImGui::GetID("##ThemesContainer"), ChildSize)) { ImVec2 TableSize = ImVec2(0, 0); if (ImGui::BeginTable("##Themes", 2, ImGuiTableFlags_SizingFixedFit|ImGuiTableFlags_NoSavedSettings|ImGuiTableFlags_ScrollY, TableSize)) { + // Text in TableSetupColumn calls not translated because they're not visible to the user. ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("Remove", 0); for (auto themePath : Theme::availableThemes) { @@ -452,7 +475,7 @@ int main(int, char**) } ImGui::EndChildFrame(); ImGui::SetNextItemWidth(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2)); - if (ImGui::SliderFloat("##AccentColor", &accent_color, 0.0, 360.0, "UI hue: %.0f°", ImGuiSliderFlags_NoRoundToFormat)) { + if (ImGui::SliderFloat("##AccentColor", &accent_color, 0.0, 360.0, _TR_CTX("Preference > Accent hue slider, range 0-360 from HSV algorithm hue component", "Accent color hue: %.0f°"), ImGuiSliderFlags_NoRoundToFormat)) { theme->Apply(accent_color); } } @@ -460,50 +483,64 @@ int main(int, char**) } if (about_window) { ImGui::SetNextWindowDockID(dockid); - if (ImGui::Begin(ICON_FK_INFO "About and Licenses", &about_window)) { + if (ImGui::Begin(_TRI_CTX(ICON_FK_INFO, "Window title, window opened by menu item", "About and Licenses"), &about_window)) { ImGui::PushFont(title); - static const string APP_NAME_STR = NAME; + static const string APP_NAME_STR = _TR_CTX("Application name - Japanese word should remain Japanese and stay the same when translating for stylistic purposes.", "ねこ Player"); ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::GetFont()->CalcTextSizeA(ImGui::GetFontSize(), FLT_MAX, 0.0f, APP_NAME_STR.c_str()).x) / 2.0f); ImGui::Text(APP_NAME_STR.c_str()); ImGui::PopFont(); - static const string VER_STRING = string("Version ") + string(TAG); + static const string APP_NAME_ROMANIZED = _TR_CTX("Application name - Japanese word should be converted to the translated language's characters. Use an empty string to disable for Japanese.", "(Neko Player)"); + if (APP_NAME_ROMANIZED != "") { + ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::GetFont()->CalcTextSizeA(ImGui::GetFontSize(), FLT_MAX, 0.0f, APP_NAME_ROMANIZED.c_str()).x) / 2.0f); + ImGui::Text(APP_NAME_ROMANIZED.c_str()); + } + static const string VER_STRING = _TR_CTX("Version string format specifier", "Version ") + string(TAG) + _TRS_CTX("Suffix to the version string in the about window, if needed", " "); ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::GetFont()->CalcTextSizeA(ImGui::GetFontSize(), FLT_MAX, 0.0f, VER_STRING.c_str()).x) / 2.0f); ImGui::Text(VER_STRING.c_str()); ImGui::NewLine(); static vector projects = { - LicenseData("Neko Player", "MIT"), - LicenseData("SDL Mixer X", "Zlib"), - LicenseData("JsonCpp", "MIT"), - LicenseData("SoundTouch", "LGPL-2.1-only"), - LicenseData("Dear ImGui", "MIT"), - LicenseData("imgui-filebrowser", "MIT"), + LicenseData(APP_NAME_STR, "MIT"), + LicenseData(_TR_CTX("Library name", "SDL Mixer X"), "Zlib"), + LicenseData(_TR_CTX("Library name", "JsonCpp"), "MIT"), + LicenseData(_TR_CTX("Library name", "SoundTouch"), "LGPL-2.1-only"), + LicenseData(_TR_CTX("Library name", "libintl"), "LGPL-2.1-only"), + LicenseData(_TR_CTX("Library name", "Dear ImGui"), "MIT"), + LicenseData(_TR_CTX("Library name", "imgui-filebrowser"), "MIT"), #ifdef PORTALS - LicenseData("libportal", "LGPL-3.0-only"), + LicenseData(_TR_CTX("Library name", "libportal"), "LGPL-3.0-only"), // Only include the license if it applies. #endif - LicenseData("Noto Sans", "OFL-1.1-RFN"), - LicenseData("Fork Awesome", "OFL-1.1-RFN"), - LicenseData("IconFontCppHeaders", "Zlib") + LicenseData(_TR_CTX("Library name", "Noto Sans"), "OFL-1.1-RFN"), + LicenseData(_TR_CTX("Library name", "Fork Awesome"), "OFL-1.1-RFN"), + LicenseData(_TR_CTX("Library name", "IconFontCppHeaders"), "Zlib") }; - LOAD_LICENSE(projects[0], nekoplayer); - LOAD_LICENSE(projects[1], sdl_mixer_x); - LOAD_LICENSE(projects[2], jsoncpp); - LOAD_LICENSE(projects[3], soundtouch); - LOAD_LICENSE(projects[4], imgui); - LOAD_LICENSE(projects[5], imgui_filebrowser); - LOAD_LICENSE(projects[6], libportal); - LOAD_LICENSE(projects[7], notosans); - LOAD_LICENSE(projects[8], forkawesome); - LOAD_LICENSE(projects[9], icnfntcpphdrs); - + // Do this in an inner scope so that 'i' isn't accidentally used outside it, + // and so that 'i' can refer to another variable such as in a for loop. + { + int i = 0; + // Use a variable instead of hardcoding so that a #ifdef can change the indices later on. + LOAD_LICENSE(projects[i], nekoplayer); i++; + LOAD_LICENSE(projects[i], sdl_mixer_x); i++; + LOAD_LICENSE(projects[i], jsoncpp); i++; + LOAD_LICENSE(projects[i], soundtouch); i++; + LOAD_LICENSE(projects[i], libintl); i++; + LOAD_LICENSE(projects[i], imgui); i++; + LOAD_LICENSE(projects[i], imgui_filebrowser); i++; + #ifdef PORTALS + LOAD_LICENSE(projects[i], libportal); i++; + #endif + LOAD_LICENSE(projects[i], notosans); i++; + LOAD_LICENSE(projects[i], forkawesome); i++; + LOAD_LICENSE(projects[i], icnfntcpphdrs); i++; + } // Left static LicenseData selected = projects[0]; { ImGui::BeginGroup(); - ImGui::TextUnformatted("Project"); + ImGui::TextUnformatted(_TR_CTX("Project selector label.", "Project")); + // Next string is internal. ImGui::BeginChild("project selector", ImVec2(150, 0), true); for (auto project : projects) { - // FIXME: Good candidate to use ImGuiSelectableFlags_SelectOnNav if (ImGui::Selectable(project.Project.c_str(), selected.Project == project.Project)) selected = project; } @@ -514,9 +551,10 @@ int main(int, char**) // Right { ImGui::BeginGroup(); - ImGui::TextUnformatted("License"); - ImGui::BeginChild("license view", ImVec2(0, 0), true); // Leave room for 1 line below us - ImGui::Text("%s: %s", selected.Project.c_str(), selected.Spdx.c_str()); + ImGui::TextUnformatted(_TR_CTX("License viewer label", "License")); + // Next string is internal. + ImGui::BeginChild("license view", ImVec2(0, 0), true); // *don't* leave room for the nonexistant line below us! + ImGui::Text(_TR_CTX("License viewer > information above license - string 1: selected project, string 2: SPDX license identifier", "%s: %s"), selected.Project.c_str(), selected.Spdx.c_str()); ImGui::Separator(); ImGui::TextWrapped("%s", selected.LicenseContents.c_str()); ImGui::EndChild(); @@ -595,6 +633,7 @@ int main(int, char**) config["demo_window"] = show_demo_window; config["vsync"] = vsync; config["framerate"] = framerate; + config["lang"] = currentLanguage; stream << config; stream.close(); } diff --git a/meson.build b/meson.build index f9317ff..7c0a4e6 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,7 @@ if get_option('gles') or target_machine.cpu_family() == 'aarch64' or target_mach endif cfg_data = configuration_data() cfg_data.set('DEBUG', get_option('debug')) +cfg_data.set('LOCALE_DIR', get_option('localedir')) # SDL Mixer X smx_opts = cmake.subproject_options() smx_opts.add_cmake_defines({'SDL_MIXER_X_STATIC': true, 'SDL_MIXER_X_SHARED': false, 'USE_MIDI_NATIVE_ALT': false, 'USE_MIDI_NATIVE': false}) @@ -25,6 +26,7 @@ deps = [ dependency('gl'), subproject('jsoncpp').get_variable('jsoncpp_dep'), dependency('soundtouch'), + dependency('intl'), smx_subproj.dependency('SDL2_mixer_ext_Static') ] @@ -55,6 +57,7 @@ srcs = [ 'playback.cpp', 'theme.cpp', 'file_browser.cpp', + 'base85.cpp', 'imgui/imgui.cpp', 'imgui/imgui_widgets.cpp', 'imgui/imgui_tables.cpp', diff --git a/theme.cpp b/theme.cpp index 04debd1..038c3a9 100644 --- a/theme.cpp +++ b/theme.cpp @@ -1,12 +1,12 @@ #include "theme.h" #include "imgui.h" #include "json/value.h" +#include "translation.h" #include #include #include #include #include -#include #include #include "IconsForkAwesome.h" @@ -33,11 +33,11 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid static bool loadOpen = false; static bool saveAsOpen = false; ImGui::SetNextWindowDockID(dockid); - ImGui::Begin(ICON_FK_MAGIC "Theme Editor", open); + ImGui::Begin(_TRI_CTX(ICON_FK_MAGIC, "Window title", "Theme Editor"), open); ImGuiStyle& style = theme->style; ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f); ImVec2 buttonSize = ImVec2((ImGui::GetWindowWidth() * 0.50f) - (ImGui::GetStyle().WindowPadding.x) - (ImGui::GetStyle().ItemSpacing.x * 0.5f), 0); - if (ImGui::Button("Create light", buttonSize)) { + if (ImGui::Button(_TR_CTX("Theme Editor > preset button", "Create light"), buttonSize)) { delete theme; theme = new Theme(false); @@ -46,7 +46,7 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid return true; } ImGui::SameLine(); - if (ImGui::Button("Create dark", buttonSize)) { + if (ImGui::Button(_TR_CTX("Theme Editor > preset button", "Create dark"), buttonSize)) { delete theme; theme = new Theme(true); @@ -54,9 +54,9 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid ImGui::End(); return true; } - if (ImGui::Button("Import...", buttonSize)) { - importDialog.SetTitle("Import theme..."); - importDialog.SetTypeFilters("Theme JSON files", { ".json"}); + if (ImGui::Button(_TR_CTX("Theme Editor > import button. Opens the theme import file dialog", "Import..."), buttonSize)) { + importDialog.SetTitle(_TR_CTX("Theme Editor file dialog title", "Import theme...")); + importDialog.SetTypeFilters(_TR_CTX("Theme Editor file dialog filter name", "Theme JSON files"), { ".json"}); std::string userdir = std::getenv( #ifdef _WIN32 "UserProfile" @@ -68,9 +68,9 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid importDialog.Open(); } ImGui::SameLine(); - if (ImGui::Button("Export...", buttonSize)) { - exportDialog.SetTitle("Export theme..."); - exportDialog.SetTypeFilters("Theme JSON files", { ".json"}); + if (ImGui::Button(_TR_CTX("Theme Editor > export button. Opens the theme export file dialog", "Export..."), buttonSize)) { + exportDialog.SetTitle(_TR_CTX("Theme Editor file dialog title", "Export theme...")); + exportDialog.SetTypeFilters(_TR_CTX("Theme Editor file dialog filter name", "Theme JSON files"), { ".json"}); std::string userdir = std::getenv( #ifdef _WIN32 "UserProfile" @@ -92,7 +92,7 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid importDialog.Display(); exportDialog.Display(); if (!theme->file_path.empty()) { - if (ImGui::Button("Revert", buttonSize)) { + if (ImGui::Button(_TR_CTX("Theme Editor > button. Reverts to saved file.", "Revert"), buttonSize)) { string file_path_backup = theme->file_path; delete theme; theme = new Theme(file_path_backup); @@ -101,75 +101,75 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid return true; } ImGui::SameLine(); - if (ImGui::Button("Save", buttonSize)) { + if (ImGui::Button(_TR_CTX("Theme Editor > button. Saves the theme to it's current location. Not shown when it doesn't already have one.", "Save"), buttonSize)) { theme->Save(theme->file_path); } } - if (ImGui::Button("Load...", buttonSize)) { + if (ImGui::Button(_TR_CTX("Theme Editor > button. Opens the theme loading dialog for themes created or imported by the user.", "Load..."), buttonSize)) { loadOpen = true; } ImGui::SameLine(); - if (ImGui::Button("Save as...", buttonSize)) { + if (ImGui::Button(_TR_CTX("Theme Editor > button. Opens the theme saving dialog for themes created or imported by the user.", "Save as..."), buttonSize)) { saveAsOpen = true; } // Simplified Settings (expose floating-pointer border sizes as boolean representing 0.0f or 1.0f) - if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f")) + if (ImGui::SliderFloat(_TR_CTX("Theme Editor > slider. Simplified frame rounding.", "Frame Rounding"), &style.FrameRounding, 0.0f, 12.0f, "%.0f")) style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding - { bool border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &border)) { style.WindowBorderSize = border ? 1.0f : 0.0f; } } + { bool border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox(_TR_CTX("Theme Editor > checkbox", "Window Border"), &border)) { style.WindowBorderSize = border ? 1.0f : 0.0f; } } ImGui::SameLine(); - { bool border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox("FrameBorder", &border)) { style.FrameBorderSize = border ? 1.0f : 0.0f; } } + { bool border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox(_TR_CTX("Theme Editor > checkbox", "Frame Border"), &border)) { style.FrameBorderSize = border ? 1.0f : 0.0f; } } ImGui::SameLine(); - { bool border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox("PopupBorder", &border)) { style.PopupBorderSize = border ? 1.0f : 0.0f; } } + { bool border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox(_TR_CTX("Theme Editor > checkbox", "Popup Border"), &border)) { style.PopupBorderSize = border ? 1.0f : 0.0f; } } ImGui::Separator(); if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None)) { - if (ImGui::BeginTabItem("Sizes")) + if (ImGui::BeginTabItem(_TR_CTX("Theme Editor > Tab label", "Sizes"))) { - ImGui::SeparatorText("Sizing"); - ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("CellPadding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); - //ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); - //ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); - ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); - ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f"); + ImGui::SeparatorText(_TR_CTX("Theme Editor > Sizes > Section label", "Sizing")); + ImGui::SliderFloat2(_TR_CTX("Theme Editor > Sizes > Sizing > label of XY sliders", "Window Padding"), (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2(_TR_CTX("Theme Editor > Sizes > Sizing > label of XY sliders", "Frame Padding"), (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2(_TR_CTX("Theme Editor > Sizes > Sizing > label of XY sliders", "Cell Padding"), (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2(_TR_CTX("Theme Editor > Sizes > Sizing > label of XY sliders", "Item Spacing"), (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2(_TR_CTX("Theme Editor > Sizes > Sizing > label of XY sliders", "Inner Item Spacing"), (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); + //ImGui::SliderFloat2(_TR_CTX("Theme Editor > Sizes > Sizing > label of XY sliders", "TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); + //ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Sizing > slider label", "IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Sizing > slider label", "Scrollbar Size"), &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Sizing > slider label", "Minimum Grabber Size"), &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2(_TR_CTX("Theme Editor > Sizes > Sizing > label of XY sliders", "Separator Text Padding"), (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f"); - ImGui::SeparatorText("Borders"); - ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("SeparatorTextBorderSize", &style.SeparatorTextBorderSize, 0.0f, 10.0f, "%.0f"); + ImGui::SeparatorText(_TR_CTX("Theme Editor > Sizes > Section label", "Borders")); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Borders > slider label", "Window Border Size"), &style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Borders > slider label", "Child Border Size"), &style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Borders > slider label", "Popup Border Size"), &style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Borders > slider label", "Frame Border Size"), &style.FrameBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Borders > slider label", "Tab Border Size"), &style.TabBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Borders > slider label", "Separator Text Border Size"), &style.SeparatorTextBorderSize, 0.0f, 10.0f, "%.0f"); - ImGui::SeparatorText("Rounding"); - ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SeparatorText(_TR_CTX("Theme Editor > Sizes > Section label", "Rounding")); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Rounding > slider label", "Window Rounding"), &style.WindowRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Rounding > slider label", "Child Rounding"), &style.ChildRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Rounding > slider label", "Frame Rounding"), &style.FrameRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Rounding > slider label", "Popup Rounding"), &style.PopupRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Rounding > slider label", "Scrollbar Rounding"), &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Rounding > slider label", "Grabber Rounding"), &style.GrabRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat(_TR_CTX("Theme Editor > Sizes > Rounding > slider label", "Tab Rounding"), &style.TabRounding, 0.0f, 12.0f, "%.0f"); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("Colors")) + if (ImGui::BeginTabItem(_TR_CTX("Theme Editor > Tab label", "Colors"))) { static ImGuiTextFilter filter; - filter.Draw("Filter colors", ImGui::GetFontSize() * 16); + filter.Draw(_TR_CTX("Theme Editor > Colors > text filter", "Filter colors"), ImGui::GetFontSize() * 16); static ImGuiColorEditFlags alpha_flags = 0; - if (ImGui::RadioButton("Opaque", alpha_flags == ImGuiColorEditFlags_None)) { alpha_flags = ImGuiColorEditFlags_None; } ImGui::SameLine(); - if (ImGui::RadioButton("Alpha", alpha_flags == ImGuiColorEditFlags_AlphaPreview)) { alpha_flags = ImGuiColorEditFlags_AlphaPreview; } ImGui::SameLine(); - if (ImGui::RadioButton("Both", alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf)) { alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf; } + if (ImGui::RadioButton(_TR_CTX("Theme Editor > Colors > preview settings radio button", "Opaque"), alpha_flags == ImGuiColorEditFlags_None)) { alpha_flags = ImGuiColorEditFlags_None; } ImGui::SameLine(); + if (ImGui::RadioButton(_TR_CTX("Theme Editor > Colors > preview settings radio button", "Alpha"), alpha_flags == ImGuiColorEditFlags_AlphaPreview)) { alpha_flags = ImGuiColorEditFlags_AlphaPreview; } ImGui::SameLine(); + if (ImGui::RadioButton(_TR_CTX("Theme Editor > Colors > preview settings radio button", "Both"), alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf)) { alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf; } ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened); ImGui::PushItemWidth(-160); @@ -180,7 +180,7 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid continue; ImGui::PushID(i); bool hueEnabled = theme->HueEnabledColors.contains(i); - if (ImGui::Checkbox("Accent", &hueEnabled)) { + if (ImGui::Checkbox(_TR_CTX("Theme Editor > Colors > (Any color) > recoloring checkbox", "Match hue preference"), &hueEnabled)) { if (hueEnabled) { theme->HueEnabledColors.insert(i); } else { @@ -217,16 +217,16 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid exportDialog.ClearSelected(); } if (loadOpen) { - ImGui::OpenPopup("Load..."); + ImGui::OpenPopup(_TR_CTX("Theme Editor > Custom modal dialog title", "Load...")); ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::SetNextWindowSize(ImVec2(window_width, window_height)); - if (ImGui::BeginPopupModal("Load...", nullptr, ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize)) { + if (ImGui::BeginPopupModal(_TR_CTX("Theme Editor > Custom modal dialog title", "Load..."), nullptr, ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize)) { static path selectedThemePath; static char filter[1024] = {0}; - ImGui::Text("Filter:"); ImGui::SameLine(); + ImGui::Text(_TR_CTX("Theme Editor > Load dialog > Theme selector > filter label", "Filter:")); ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::GetWindowWidth() - ImGui::GetCursorPosX() - ImGui::GetStyle().WindowPadding.x); ImGui::InputText("##FilterInput", filter, 1024); - ImGui::Text("Available themes..."); + ImGui::Text(_TR_CTX("Theme Editor > Load dialog > Theme selector > label", "Available themes...")); if (ImGui::BeginListBox("##Themes", ImVec2(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f), -ImGui::GetTextLineHeightWithSpacing() - ImGui::GetStyle().WindowPadding.y))) { for (auto themePath : Theme::availableThemes) { if (themePath.stem().string().starts_with(filter)) { @@ -241,7 +241,7 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid } ImGui::EndListBox(); } - if (ImGui::Button("Load")) { + if (ImGui::Button(_TR_CTX("Theme Editor > Load dialog > Load button", "Load"))) { if (!selectedThemePath.empty()) { filter[0] = '\0'; loadOpen = false; @@ -253,7 +253,7 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid } } ImGui::SameLine(); - if (ImGui::Button("Cancel")) { + if (ImGui::Button(_TR_CTX("Theme Editor > Load dialog > Cancel button", "Cancel"))) { selectedThemePath = path(); filter[0] = '\0'; loadOpen = false; @@ -262,16 +262,16 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid } } if (saveAsOpen) { - ImGui::OpenPopup("Save as..."); + ImGui::OpenPopup(_TR_CTX("Theme Editor > Custom modal dialog title", "Save as...")); ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::SetNextWindowSize(ImVec2(window_width, window_height)); - if (ImGui::BeginPopupModal("Save as...", nullptr, ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize)) { + if (ImGui::BeginPopupModal(_TR_CTX("Theme Editor > Custom modal dialog title", "Save as..."), nullptr, ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize)) { static char selectedThemeName[1024] = {0}; static char filter[1024] = {0}; - ImGui::Text("Filter:"); ImGui::SameLine(); + ImGui::Text(_TR_CTX("Theme Editor > Save as dialog > Theme selector > filter label", "Filter:")); ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::GetWindowWidth() - ImGui::GetCursorPosX() - ImGui::GetStyle().WindowPadding.x); ImGui::InputText("##FilterInput", filter, 1024); - ImGui::Text("Available themes..."); + ImGui::Text(_TR_CTX("Theme Editor > Save as dialog > Theme selector > label", "Available themes...")); if (ImGui::BeginListBox("##Themes", ImVec2(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f), -ImGui::GetFrameHeightWithSpacing() - ImGui::GetTextLineHeightWithSpacing() - ImGui::GetStyle().WindowPadding.y))) { for (auto themePath : Theme::availableThemes) { if (themePath.stem().string().starts_with(filter)) { @@ -287,8 +287,8 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid ImGui::EndListBox(); } ImGui::SetNextItemWidth(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f)); - ImGui::InputText("Theme name: ", selectedThemeName, 1024); - if (ImGui::Button("Save")) { + ImGui::InputText(_TR_CTX("Theme Editor > Save as dialog > Theme name input label", "Theme name: "), selectedThemeName, 1024); + if (ImGui::Button(_TR_CTX("Theme Editor > Save as dialog > Save button", "Save"))) { path selectedThemePath(selectedThemeName); if (!selectedThemePath.empty() && !selectedThemePath.is_absolute()) { selectedThemeName[0] = '\0'; // This empties the string by taking advantage of C strings. @@ -299,7 +299,7 @@ bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_wid } } ImGui::SameLine(); - if (ImGui::Button("Cancel")) { + if (ImGui::Button(_TR_CTX("Theme Editor > Save as dialog > Cancel button", "Cancel"))) { selectedThemeName[0] = '\0'; // Same as above filter[0] = '\0'; saveAsOpen = false; @@ -331,6 +331,23 @@ void Theme::Save(string path) { Json::Value config; std::ofstream stream; stream.open(path); + { + Json::Value metadata; + metadata["SchemaVersion"] = 1; + { + Json::Value stringsList; + for (auto kv : strings) { + Json::Value stringsEntry; + string language = kv.first; + ThemeStrings strings = kv.second; + stringsEntry["Name"] = strings.name; + stringsEntry["Description"] = strings.description; + stringsList[language] = stringsEntry; + } + metadata["Strings"] = stringsList; + } + config["meta"] = metadata; + } { Json::Value rounding; rounding["Frame"] = style.FrameRounding; @@ -430,12 +447,33 @@ Theme::Theme(bool dark) : Theme() { style.GrabRounding = 12; style.WindowRounding = 12; } +ThemeStrings::ThemeStrings() { + name = _TRS_CTX("Theme default strings > name", "A theme"); + description = _TRS_CTX("Theme default strings > description", "(No description)"); +} Theme::Theme(string path) : Theme() { Json::Value config; std::ifstream stream; stream.open(path); if (stream.is_open()) { stream >> config; + if (config.isMember("meta")) { + Json::Value metadata = config["meta"]; + //metadata["SchemaVersion"] = 1; + if (metadata.isMember("Strings")) { + Json::Value stringsList = metadata["Strings"]; + for (string language : stringsList.getMemberNames()) { + Json::Value stringsEntry = stringsList[language]; + ThemeStrings strings; + if (stringsEntry.isMember("Name")) { + strings.name = stringsEntry["Name"].asString(); + } + if (stringsEntry.isMember("Description")) { + strings.description = stringsEntry["Description"].asString(); + } + } + } + } if (config.isMember("rounding")) { Json::Value rounding = config["rounding"]; style.FrameRounding = rounding["Frame"].asFloat(); diff --git a/theme.h b/theme.h index d5509a9..2b4f0c2 100644 --- a/theme.h +++ b/theme.h @@ -2,12 +2,20 @@ #include "config.h" #include "imgui.h" #include +#include #include #include "file_browser.h" +#include #include using std::string; using namespace std::filesystem; +struct ThemeStrings { + string name; + string description; + ThemeStrings(); +}; + class Theme { ImGuiStyle style; @@ -16,7 +24,10 @@ class Theme { static void updateAvailableThemes(); static path themeDir; static const char* prefPath; + static const int MinSchemaVersion = 0; + static const int MaxSchemaVersion = 1; string file_path; + std::map strings; std::set HueEnabledColors; static bool ShowEditor(bool *open, Theme* &theme, ImGuiID dockid, int window_width, int window_height); void Apply(float hue); diff --git a/translation.cpp b/translation.cpp new file mode 100644 index 0000000..83a5021 --- /dev/null +++ b/translation.cpp @@ -0,0 +1 @@ +#include "translation.h" \ No newline at end of file diff --git a/translation.h b/translation.h new file mode 100644 index 0000000..55557b3 --- /dev/null +++ b/translation.h @@ -0,0 +1,23 @@ +#pragma once +#include +#include +#include +// Based on the code found in gettext.h, but without any additionall things we don't need. +inline static const char *gettext_ctx(const char *ctx, const char *msgid) { + const char *msg_ctxt_id = (std::string(ctx) + std::string("\004") + std::string(msgid)).c_str(); + const char *translation = gettext(msg_ctxt_id); + if (translation == msg_ctxt_id) { + return msgid; + } else { + return translation; + } +} +#define _TR(str) gettext(str) +#define _TR_CTX(ctx, str) gettext_ctx(ctx, str) +#define _TRS(str) std::string(_TR(str)) +#define _TRS_CTX(ctx, str) std::string(_TR_CTX(ctx, str)) +#define _TRIS(icon, str) (std::string(icon) + _TRS(str)) +#define _TRI(icon, str) _TRIS(icon, str).c_str() +#define _TRIS_CTX(icon, ctx, str) (std::string(icon) + _TRS_CTX(ctx, str)) +#define _TRI_CTX(icon, ctx, str) _TRIS_CTX(icon, ctx, str).c_str() +static std::string currentLanguage; \ No newline at end of file