Code Monkey home page Code Monkey logo

Comments (3)

marcantondahmen avatar marcantondahmen commented on August 13, 2024 1

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.

LaserStefan avatar LaserStefan commented on August 13, 2024

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.

evij-g avatar evij-g commented on August 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.