# Approach for multi-language with Lime

**URL:** <https://discourse.getcockpit.com/t/approach-for-multi-language-with-lime/2124>\
**Category:** General\
**Created:** [October 29, 2021, 10:24am UTC](https://discourse.getcockpit.com/t/approach-for-multi-language-with-lime/2124 "2021-10-29T10:24:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tokant](https://avatars.discourse-cdn.com/v4/letter/t/90db22/32.png) [@tokant](https://discourse.getcockpit.com/u/tokant)\
**Post date:** [October 29, 2021, 10:24am UTC](https://discourse.getcockpit.com/t/approach-for-multi-language-with-lime/2124/1 "2021-10-29T10:24:16Z")

</div>

There are probably endless approaches to building the frontend logic regarding multi-language with Lime framework. But does anyone have a simple, proven method that works?

My site has English as default and German as secondary language. So the URL structure I’d like for the homepage is:  
Default homepage: [https://domain.tld](https://domain.tld)  
German homepage: [https://domain.tld/de](https://domain.tld/de)

For this I used the $params variable, which works well:

$app-\>bind("/:lang", function($params) use($app) {  
$posts = cockpit(‘collections’)-\>find(‘news’, [“lang” =\> $params[‘lang’]]);  
return $this-\>render(“views/frontpage.php with views/layout.php”, array(‘posts’ =\> $posts));  
});

But the $params does not work for subpages, for example:  
Default subpage: [https://domain.tld/subpage\_slug](https://domain.tld/subpage_slug)  
German subpage: [https://domain.tld/de/subpage\_slug](https://domain.tld/de/subpage_slug)

For the subpage /article/ I tried the following without success:

$app-\>bind("/:lang/article/:id", function($params) use($app) {  
$post = cockpit(‘collections’)-\>findOne(‘news’, ["\_id" =\> $params[‘id’], “lang” =\> $params[‘lang’]]);  
return $this-\>render(“views/article.php with views/layout.php”, array(‘post’ =\> $post));  
});

How would you build the logic?

Also, do you have any tips on creating a language switcher?  
This code seems a bit hacky:

$config = cockpit()[‘app.config’];  
$db = cockpit()-\>db;  
$locales = array\_merge([$config[‘i18n’]], $db-\>getKey(“cockpit/settings”, “cockpit.locales”, []));

Thanks!
