Mindaugas Posted August 25, 2013 Share Posted August 25, 2013 Hello, i missed some good futures in processwire so i decided to write my own module to do it. In Github: https://github.com/GomatoX/Language-Constants/ Installation is the same as other modules installation. Language constant module creates language_constants table in database. Purpose: This module helps to keep texts editable in cms, not hardcoded. For example, I want to have editable back button text: "back to main", so I just need to add it into language constants modulue as a constant and it would be reachable everywhere in page. How to use: Simply use $lang class and it's method display, example: $lang->display( 'constant_name' ); display( string $constant_name ) returns language constant variable. Known issues ( todo in future ): There is no available support if multilanguage is installed. No cache for constants. Needs optimization. *Still in beta conditions, posted for tests. 3 Link to comment Share on other sites More sharing options...
ryan Posted August 27, 2013 Share Posted August 27, 2013 GomatoX, thanks for your module. Can you describe what language constants are and how users would utilize them? What would be the benefits over using the existing translation system or multilanguage page fields? I'm on mobile, but when I get to my computer I'll try it out and probably find the answer myself, but wanted to pose the question for the benefit of other users that may be interested. 1 Link to comment Share on other sites More sharing options...
Mindaugas Posted August 27, 2013 Author Share Posted August 27, 2013 GomatoX, thanks for your module. Can you describe what language constants are and how users would utilize them? What would be the benefits over using the existing translation system or multilanguage page fields? I'm on mobile, but when I get to my computer I'll try it out and probably find the answer myself, but wanted to pose the question for the benefit of other users that may be interested. Thanks, I done it. Updated my previous post, and i think it's clear to understand why I'm not using other language modules. Link to comment Share on other sites More sharing options...
WillyC Posted August 28, 2013 Share Posted August 28, 2013 coolbot .how difrent.from __('constent_namme'); mindaug aso ? http://processwire.com/api/multi-language-support/code-i18n/ Link to comment Share on other sites More sharing options...
Mindaugas Posted August 28, 2013 Author Share Posted August 28, 2013 coolbot .how difrent.from __('constent_namme'); mindaug aso ? http://processwire.com/api/multi-language-support/code-i18n/ Okey, i will test it in this afternoon, but what about if you have one language, still you need to hardcode texts? How to change it's primary value only in cms? Link to comment Share on other sites More sharing options...
ryan Posted August 29, 2013 Share Posted August 29, 2013 Okey, i will test it in this afternoon, but what about if you have one language, still you need to hardcode texts? How to change it's primary value only in cms? It's basically a gettext style system (that doesn't use gettext) where the actual language represents the keys rather than a placeholder constant or variable. Anything you put in a __('Hello World'); function call essentially becomes a language constant (if I understand the term correctly). Even if you only have one language installed (default), you can still translate the text in the admin and have the output affected. The benefits in a single-language environment are perhaps even greater, in that you only need to translate the terms you want to change. It's a handy way to enable content management of static text. But I didn't design it, as it's the standard upon which most text translation engines work (most being gettext based). Regarding your module, is it possible for you to change the class and filename from "language_constants" to "LanguageConstants" or something else with the U&LC format? The reason goes beyond consistency: our modules directory and installers expect the format and other formats may cause technical issues. 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