@@ -16,9 +16,16 @@ composer require peterujah/php-google-translator
1616
1717# USAGES
1818
19+ Initalize with page languages
1920``` php
2021use Peterujah\NanoBlock\GTranslator;
21- $translate = new GTranslator("en", "/assets/flags/");
22+ $translate = new GTranslator(substr(($_SERVER['HTTP_ACCEPT_LANGUAGE']??"en"), 0, 2), "/assets/flags/");
23+ ```
24+
25+ Or with icon path
26+ ``` php
27+ use Peterujah\NanoBlock\GTranslator;
28+ $translate = new GTranslator(substr(($_SERVER['HTTP_ACCEPT_LANGUAGE']??"en"), 0, 2));
2229```
2330
2431set selector design provider, you can choose between ` DEFAULT ` , ` SELECT ` or ` BOOTSTRAP. `
@@ -27,19 +34,24 @@ The `DEFAULT` is the default provider
2734$translate->setProvider(GTranslator::DEFAULT || GTranslator::SELECT || GTranslator::BOOTSTRAP);
2835```
2936
30- Set the fag icon type, ` PNG ` or ` SVG ` to use icons download country flag icon and set the Relative or Absolute path
37+ Set languages icon path and icon type ` GTranslator::PNG || GTranslator::SVG ` .
38+ ` PNG ` or ` SVG ` to use icons download country language flag icon and set the Relative or Absolute path
39+
40+ ``` php
41+ $translate->setIconPath("https://foo.com/assets/flags/", GTranslator::PNG);
42+ ```
43+ Or set individually by first setting path and then type to override the default type
3144
3245``` php
33- $translate->setIconType(GTranslator::PNG || GTranslator::SVG);
34- $translate->setIconPath("https://foo.com/assets/flags/");
46+ $translate->setIconPath("/assets/flags/")->setIconType(GTranslator::PNG);
3547 ```
36- Add additional langues
3748
49+ Adding additional language to translator
3850 ``` php
3951 $translate->addLanguage("en", "English")->addLanguage("ig", "Igbo");
4052 ```
4153
42- Load languages
54+ Or load your languages to override the default
4355
4456 ``` php
4557 $translate->setLanguages([
@@ -56,6 +68,11 @@ $translate->setIconPath("https://foo.com/assets/flags/");
5668 When your provider is ` GTranslator::SELECT ` , button will return a html select option
5769 ``` php
5870 $translate->button();
71+ ```
72+
73+ To use image button, your provider must be ` GTranslator::DEFAULT `
74+ ``` php
75+ $translate->imageButton();
5976 ```
6077
6178 Load supportes javascript plugin
@@ -65,7 +82,7 @@ $translate->setIconPath("https://foo.com/assets/flags/");
6582
6683 Force translate page once pages is loaded, this must be called after ` $translate->load(); `
6784 ``` php
68- $translate->forceLanguage("ms");
85+ $translate->forceLanguage("ms");
6986 ```
7087
7188 Full usage on website to translate webpage
@@ -94,7 +111,7 @@ $translate->setIconPath("https://foo.com/assets/flags/");
94111 We believe in banking locally and hope you will too.
95112 </p >
96113 </div >
97- <?php $translate->load();$translate->forceLanguage("jp" );?>
114+ <?php $translate->load();$translate->forceLanguage($translate->siteLang );?>
98115 </body >
99116</html >
100117```
0 commit comments