Comments (4)
In order to do this server-side, we'd need to take out all Dropplets hard-coded strings and replace them with a function, like so:
<a class="powered-by" target="_blank" href="http://dropplets.com"><img src="http://jimmythompson.co.uk/blog/dropplets/style/images/powered-by.png"></img>
Powered by Dropplets
</a>
... would become ...
<a class="powered-by" target="_blank" href="http://dropplets.com"><img src="http://jimmythompson.co.uk/blog/dropplets/style/images/powered-by.png"></img>
<?php echo international("Powered by Dropplets"); ?>
</a>
The international
function would look like:
function international($key) {
if(in_array($key, $translations)) {
return $translations[$key];
}
return $key;
}
This way, should a translation not exist, the site will automatically default back to English.
from dropplets.
couldn't you just use gettext strings? (e.g. __(), _n, _e)
from dropplets.
That sounds like a much better idea. 👍
I didn't even know such a thing existed, my apologies.
from dropplets.
I only know i18n in a WordPress context, but the functions themselves are generic php functions. The basic idea is you wrap your test strings in a php function like the ones I've listed, so:
<a class="powered-by" target="_blank" href="http://dropplets.com"><img src="http://jimmythompson.co.uk/blog/dropplets/style/images/powered-by.png"></img>
<?php _e( 'Powered by Dropplets', 'dropplets' ); ?>
</a>
Then when you run your code through gettext (e.g. with a translation program like Poedit, although you can do this with a php function as well), you tell it to look for _e and __ and _n and any other localization functions you're using and it will pull out those text strings that are wrapped in those functions and allow you to generate .po/.mo language files which can be used for translating the program.
There may be more that I'm not thinking of in terms of calling and initializing the language files because I haven't dug deep into how WordPress uses the language files once they are there, but the first step would be just getting it ready for gettext.
Note: your method isn't far off and could actually work if the function international
was added to Poedit when you were creating the .pot file, but I don't think it would be strictly necessary unless there were things you were doing in the function that weren't being done otherwise (say stripping out html entities or something).
from dropplets.
Related Issues (20)
- Post url HOT 2
- Html tags HOT 3
- URL to a single post page not work. HOT 1
- Will Markdown return in 2.0? HOT 2
- Slight vulnerability
- Documentation website + Dropplets v1 question HOT 1
- Anyone using version 2.0 beta? HOT 2
- Apostrophe in post content causes error HOT 3
- How to upload pictures or files? HOT 1
- Add internal image and CSS upload support
- Change the default timezone HOT 1
- uploading files ? HOT 1
- How do I reset the password? HOT 1
- Files missing from folder SleekDB HOT 14
- Draft post should only show up for logged-in users
- Demo Page? HOT 1
- Featured images not showing on homepage HOT 2
- Add Ukrain lang
- SEF URL
- 404 after settings in new install HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropplets.