kixe Posted October 17, 2013 Share Posted October 17, 2013 I created a Modul which extends Language Translator (Core) Modul, with a select-field to choose translatable files not translated yet. But it doesn't work perfectly, because the language to be translated isn't set by default. Even if I use the Standard Language Translator,no translated files will be listed. Even then, if I have set translation files for all my languages.If I go to setup -> language, choose a language and start to edit a translation file, the language-to-translate will be set in the system. Now I can go to the Language Translator and it looks like I had expected:Just to be clear I am not talking about the user language.I think it would be useful either to have a Language Selector in the Module Language Translator to select the language before the files are (not) displayed, or to set a default language-to-translate, which will be displayed in the Head of Language Translator to be clear which language is in processing.I will have a deeper look to find a solution.1 hour later: looks like it would work now. I initialized the modul with the users language by default, if nothing else is set (GET or SESSION) I made an update on github.Maybe its a better idea to make the Language-Translator a Child Page of the specific Language Page. ... or to go sleepingGood Night ...17.10.13Updated the Module today with a Language Switcher and a clear headline which let you know in which language you are. Working fine on my System now.Looks like:@experts: please checkGet the Module here: https://github.com/kixe/ProcessLanguageTranslatorPlusor here: http://modules.processwire.com/modules/process-language-translator/ 6 Link to comment Share on other sites More sharing options...
SadlyMistaken Posted October 18, 2013 Share Posted October 18, 2013 Wooooow!!!!Amazing!!! Thanks so much, I really need this!!!I'd love to know what needs translation... and Tahhhdaaaahhh!! here you are!!! Thanks Link to comment Share on other sites More sharing options...
Soma Posted October 28, 2013 Share Posted October 28, 2013 This module can't be installed with ModulesManager as it says it's already installed due to the class name being the one in the core "ProcessLanguageTranslator". 2 Link to comment Share on other sites More sharing options...
kixe Posted October 29, 2013 Author Share Posted October 29, 2013 Thanks for the note. Correction is done. 1 Link to comment Share on other sites More sharing options...
apeisa Posted November 1, 2013 Share Posted November 1, 2013 Great module, thanks for building it! Link to comment Share on other sites More sharing options...
Soma Posted November 7, 2013 Share Posted November 7, 2013 What I'm doing wrong. I installed module and changed the process of LanguageTranslator in admin to use the TranslatorPlus, but nothing changed and still get the same language translator. Also for me the LanguageTranslator admin page isn't locked for me. I'm using latest PW dev. Link to comment Share on other sites More sharing options...
Soma Posted November 7, 2013 Share Posted November 7, 2013 Hmm, ok maybe I'm dumb but didn't see that only the add new translation screen has changed. I get this warning: Notice: Undefined variable: lang in /.../site/modules/ProcessLanguageTranslatorPlus/ProcessLanguageTranslatorPlus.module on line 113 Link to comment Share on other sites More sharing options...
kixe Posted November 8, 2013 Author Share Posted November 8, 2013 @somathanks for your help in debugging. bug fixed.Got the following Error while trying to install the module via modules manager without required installation:Error: Class 'ProcessLanguageTranslator' not found (line 21 of /Users/c/Sites/processwire/sitet/modules/ProcessLanguageTranslatorPlus/ProcessLanguageTranslatorPlus.module)Installation via admin > modules is impossible(disabled) without required Installations.How can I fix this? Link to comment Share on other sites More sharing options...
Soma Posted November 8, 2013 Share Posted November 8, 2013 You could install the modules required by adding another rule to info array "installs" => "ProcessLanguageSupport" or "installs" => array("ProcessLanguageSupport","AnotherOne"); That will install those modules before yours. Or you can install them in the install routine of your module simply with a get() call wire("modules")->get("ProcessLanguageSupport"); From the perspective of modules manager I'm not sure I can add something that would check. I'm interested what happens when you install your module using core "New" feature. You enter your modules class name and it will ask to download it if found. Link to comment Share on other sites More sharing options...
ryan Posted November 9, 2013 Share Posted November 9, 2013 If it requires ProcessLanguageSupport, wouldn't you want it to be "requires" => "ProcessLanguageSupport" ? Link to comment Share on other sites More sharing options...
kixe Posted November 10, 2013 Author Share Posted November 10, 2013 @ryanModule requires ProcessLanguageTranslator which is part of ProcessLanguageSupport. No effect on the error. Do you recommend to change that? Why?@Somatried out all options. Still get the Error without changing the following. class ProcessLanguageTranslatorPlus extends ProcessLanguageTranslator { ... Error occurs because the class to be extended couldn't be found. How to prevent from an Error if a downloaded module extends a non existing or not installed class? Any experiences? Link to comment Share on other sites More sharing options...
Soma Posted November 10, 2013 Share Posted November 10, 2013 That seems a problem both ModulesManager download/install and core Modules "New" download/install suffers from. Problem seems to be that calling getModuleInfo() inits the module and since ProcessLanguageTranslator isn't installed yet, it throws the error because the class isn't loaded. I fixed it with a little workaround. So it will disable installing when there's requirements that aren't yet met. I pushed an update to ModulesManager just now. Also with some little improvements to the data table. Link to comment Share on other sites More sharing options...
ryan Posted November 12, 2013 Share Posted November 12, 2013 @ryanModule requires ProcessLanguageTranslator which is part of ProcessLanguageSupport. No effect on the error. Do you recommend to change that? Why? Sorry, I wasn't thinking about the fact that your module actually extends ProcessLanguageTranslator. What you'd need to do instead is include the ProcessLanguageTranslator.module file somewhere outside of your class. I would put this before the class definition. require(wire("config")->paths->modules . "LanguageSupport/ProcessLanguageTranslator.module"); You may also be able to do this (below) instead, but it would have the effect of installing the ProcessLanguageTranslator module, which you may not want or need to do in this case. wire("modules")->get("ProcessLanguageTranslator"); Link to comment Share on other sites More sharing options...
Soma Posted November 12, 2013 Share Posted November 12, 2013 I don't think he needs to do anything, but ModulesManager and Core modules manager (download/install) I reported issue on github for this. I got it working by cycling all modules and calling their $modules->getModuleInfo(modulename); which will not install the module but init it. This is the only way I found to still be able to call getModuleInfo on the module after downloading to check for requirements and show install button or not. Because now both modules manager are missing this step and just show install button. It is no problem on the listing (table view) as there is all this happening already and checked for "requires". Link to comment Share on other sites More sharing options...
ryan Posted November 16, 2013 Share Posted November 16, 2013 Does using require() in the module not work in this case? This is typically what any PHP class that extends another needs to do (require the class it's extending). That's of course in lieu of an autoload or something else doing it. If there's a way we can do it for them that's great, but cycling all the modules is kind of an expensive operation. I've also been thinking that I could have PW's core Modules.php parse the getModuleInfo() on it's own separately from PHP (loading it as a text file), bypassing any requirements needed by the class definition. Or just providing the option for the way PW1 did it: a separate ini or json file for the module info (i.e. MyModule.info). Link to comment Share on other sites More sharing options...
kixe Posted November 18, 2013 Author Share Posted November 18, 2013 @Somathanks for updating Modules Manager to 1.0.9.@ryanWould be nice to disable Installation Button in Admin > Modules > New, as it is already set in Admin > Modules > Site.On the other hand, isn't it anyway better to put the requirements outside the class? Link to comment Share on other sites More sharing options...
kixe Posted November 18, 2013 Author Share Posted November 18, 2013 Tested first way Ryan recommended.Loading http://mysite/processwire/module/ is impossible after placing the requirement outside the class like: require(wire("config")->paths->modules . "LanguageSupport/ProcessLanguageTranslator.module"); Got this error:Compile Error: Cannot redeclare class ProcessLanguageTranslator (line 350 of xxx/wire/modules/LanguageSupport/ProcessLanguageTranslator.module) Link to comment Share on other sites More sharing options...
ryan Posted November 23, 2013 Share Posted November 23, 2013 If you are getting a redeclare error, then you'd just use require_once() rather than require(). That tells PHP to include the file only if it hasn't already been included. That should accommodate either situation. Link to comment Share on other sites More sharing options...
Soma Posted March 10, 2014 Share Posted March 10, 2014 How does it come that some files that are translatable are not shown in the select, and since I can't enter one manually after this module is installed I have to deinstall it. For example wire/modules/Fieldtype/FieldtypeComments/CommentForm.php isn't in select. EDIT: Stupid me didn't see that CommentForm.php was already added, so it doesn't show... Link to comment Share on other sites More sharing options...
kixe Posted September 16, 2014 Author Share Posted September 16, 2014 This module is no longer updated. Because the feature is included in Core (2.4.18 dev) now. Thanks for using it. 1 Link to comment Share on other sites More sharing options...
dotnetic Posted December 26, 2018 Share Posted December 26, 2018 @kixe @kongondo Should this thread be removed, because it is integrated into the core? It could mislead others. Link to comment Share on other sites More sharing options...
dotnetic Posted December 26, 2018 Share Posted December 26, 2018 @kixe I think the module entry on the ProcessWire module page should also be removed, as it has no use anymore. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now