• Resolved pizzacolomba

    (@pizzacolomba)


    First of all, thank you for this wonderful plugin.
    I have a multilanguage (English and Italian) site where the decimal separator and the thousand separator are different (decimal separator is ‘.’ in English and ‘,’ in Italian while thousand separator is ‘,’ in English and ‘.’ in Italian. I am using polylang plugin to manage these two languages. Does m chart plugin support different settings? If not, how can I manage to represent number correctly in the two languages?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author methnen

    (@methnen)

    @pizzacolomba The plugin doesn’t support this natively but it would be relatively easy to add via one of the existing filter hooks. I’m assuming you are using Highcharts? I’m not sure Chart.js even supports changes to comma/decimal uses it’s latest version.

    In any case there’s the m_chart_chart_options filter hook:(

    https://github.com/methnen/m-chart/wiki/Action-and-filter-hooks#m_chart_chart_options

    If you wanted to add something like this to your functions.php file in your theme I imagine it would work:

    
    function filter_m_chart_chart_args( $chart_args, $post, $post_meta, $args ) {
    	if ( ADD CONDITION HERE FOR ALTERNATE LANGUAGE ) {
    		$chart_args['lang'] = array(
    	        'decimalPoint' => '.',
    			'thousandsSep' => ',',
    			'numericSymbols' => array(
    				'K', 
    				'M', 
    				'B', 
    				'T', 
    				'P', 
    				'E',
    			),
    			'numericSymbolMagnitude' => '1000',
    		);
    	} else {
    		$chart_args['lang'] = array(
    	        'decimalPoint' => '.',
    			'thousandsSep' => ',',
    			'numericSymbols' => array(
    				'K', 
    				'M', 
    				'B', 
    				'T', 
    				'P', 
    				'E',
    			),
    			'numericSymbolMagnitude' => '1000',
    		);
    	}
    
    	return $chart_args;
    }
    
    add_filter( 'm_chart_chart_args', 'filter_m_chart_chart_args', 10, 4 );
    

    Obviously you’d have to tweak the first conditional to check for the alternate language however is appropriate for your plugin, and then update the language options to match.

    Does that get you anywhere?

    • This reply was modified 4 years, 6 months ago by methnen.
    Plugin Author methnen

    (@methnen)

    Closing this since the OP never replied.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different settings for different languages’ is closed to new replies.