vannut / statamic-weather-addon

🎏 A Statamic-Addon for the OpenWeathermap API
5 stars 0 forks source link

Add a language parameter field to the cp settings #5

Closed Wibbmer closed 2 years ago

Wibbmer commented 2 years ago

By adding a select for the lang tag to the blueprint in Settings.php

'lang' => [`
          'width' => 100,
          'type' => 'select',
          'default' => 'EN',
          'options' => [
          'af' => 'Afrikaans',
          'al' => 'Albanian',
          'ar' => 'Arabic',
          'az' => 'Azerbaijani',
          'bg' => 'Bulgarian',
          'ca' => 'Catalan',
          'cz' => 'Czech',
          'da' => 'Danish',
          'de' => 'German',
          'el' => 'Greek',
          'en' => 'English',
          'eu' => 'Basque',
          'fa' => 'Persian (Farsi)',
          'fi' => 'Finnish',
          'fr' => 'French',
          'gl' => 'Galician',
          'he' => 'Hebrew',
          'hi' => 'Hindi',
          'hr' => 'Croatian',
          'hu' => 'Hungarian',
          'id' => 'Indonesian',
          'it' => 'Italian',
          'ja' => 'Japanese',
          'kr' => 'Korean',
          'la' => 'Latvian',
          'lt' => 'Lithuanian',
          'mk' => 'Macedonian',
          'no' => 'Norwegian',
          'nl' => 'Dutch',
          'pl' => 'Polish',
          'pt' => 'Portuguese',
          'pt_br' => 'Português Brasil',
          'ro' => 'Romanian',
          'ru' => 'Russian',
          'se' => 'Swedish',
          'sk' => 'Slovak',
          'sl' => 'Slovenian',
          'es' => 'Spanish',
          'sr' => 'Serbian',
          'th' => 'Thai',
          'tr' => 'Turkish',
          'uk' => 'Ukrainian',
          'vi' => 'Vietnamese',
          'zh_cn' => 'Chinese Simplified',
          'zh_tw' => 'Chinese Traditional',
          'zu' => 'Zulu',
          ],
     'instructions' => 'select your language of choice, default EN',
    ],

and adding the following line to $endpoint in FetchForecast.php

.'&lang='.$this->config->get('lang')

you're able to choose in which language the results will be delivered, from within the control panel :)

Edit: fixed formatting a little

vannut commented 2 years ago

Thank you. I just released a new version containing this addition.