Comments (3)
The second alpha of Automad 2 has been released yesterday. You can enable the new language router in the system settings in order to serve pages based on a vistor's language.
from automad.
Implementing an interactive/a visual mode for the internalisation seems to be too complicated, I've decided to set up two sites with a link to the other in the header. Works fine.
from automad.
I think to get a real multi-language support, there should be a global setting, where you define your supported languages. then each Block (text, image, etc.) should reflect these settings and extend its input fields.
here is some example from:
https://github.com/marcantondahmen/automad-theme-skeleton/blob/master/session.php
`<@ if @{ %lang } != "de" @>
This template illustrates the use of session data to build a multilingual website. Click on a language button below to switch between English and German content or use the language stored in the session data array. Click the "Use Session Setting" button to see that the selected language persits even though there is no "lang" parameter within the URL.
<@ else @>
Dieses Template verdeutlicht die Nutzung von Sessions, um eine multilinguale Website zu erstellen. Klicke auf einen der Buttons unten, um zwischen Englisch und Deutsch zu wechseln, oder die Spracheinstellung aus dem Session Array zu laden. Klicke auf den "Use Session Setting" Button, um zu sehen, dass die ausgewählte Sprache auch angezeigt wird, wenn die URL keinen "lang" Parameter hat.
<@ end @>`
and for example the basic "paragraph"-block:
https://github.com/marcantondahmen/automad/blob/v2/automad/src/server/Blocks/Paragraph.php
namespace Automad\Blocks;
use Automad\Core\Automad;
defined('AUTOMAD') or die('Direct access not permitted!');
/**
- The paragraph block.
- @author Marc Anton Dahmen
- @copyright Copyright (c) 2020-2021 by Marc Anton Dahmen - https://marcdahmen.de
- @license MIT license - https://automad.org/license
/
class Paragraph extends AbstractBlock {
/*-
Render a paragraph block.
-
@param object $data
-
@param Automad $Automad
-
@return string the rendered HTML
*/
public static function render(object $data, Automad $Automad) {
$classes = array();
$text = htmlspecialchars_decode($data->text);if (!empty($data->large)) {
$classes[] = 'am-paragraph-large';
}if (!empty($data->alignment)) {
if ($data->alignment == 'center') {
$classes[] = 'am-center';
}
}$class = self::classAttr($classes);
return "<p $class>$text
";
}
}
-
combined with your approach this could look like this:
class Paragraph extends AbstractBlock {
/**
* Render a paragraph block.
*
* @param object $data
* @param Automad $Automad
* @return string the rendered HTML
*/
public static function render(object $data, Automad $Automad) {
$classes = array();
$text = htmlspecialchars_decode($data->text);
if (!empty($data->large)) {
$classes[] = 'am-paragraph-large';
}
if (!empty($data->alignment)) {
if ($data->alignment == 'center') {
$classes[] = 'am-center';
}
}
$class = self::classAttr($classes);
return "<p $class>
<@ if @{ %lang } = 'de' and @{ textGerman } @> @{ textGerman | markdown }
<@ else @> @{ textEnglish | markdown } <@ end @>
</p>";
}
}
then somewhere where the input field is being generated, there should be a query where additional fields are generated for all specified languages in the multi-language variable.
from automad.
Related Issues (20)
- Please, add a normal localization system and commenting system! HOT 1
- Feature Request: Option to open link in new tab HOT 2
- "No main theme defined" error on scratch v2 installation. HOT 1
- Docker Installation: Provide Folder Option for Persistent Data HOT 1
- Login broken: UserCollectionModel.php HOT 6
- When version 2 is going to release? HOT 4
- HTML anchor tags break the caption editor
- PageList sort by publication date HOT 2
- Localized date HOT 2
- File upload broken by huge images HOT 3
- Pagelist: display only future events HOT 2
- automad/dist/blocks/main.bundle.css is not exists in release HOT 3
- Migration assistant for version 2 HOT 2
- Cache Issue
- Internationalization Issue
- Small Cosmetic Issue
- Automad v2 template selection problem. HOT 5
- [QUESTION] placement or removal of copyright footer HOT 2
- Internal corruption of phar error HOT 9
- Error in loading the image HOT 4
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 automad.