Jump to content

Language Constants


Mindaugas
 Share

Recommended Posts

Hello, i missed some good futures in processwire so i decided to write my own module to do it.
 
In Github:
 
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.

post-1726-0-70438700-1377628962_thumb.pn

post-1726-0-66951300-1377629090_thumb.pn

  • Like 3
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...