Git Product home page Git Product logo

labels's Introduction

Labels

This extension allows you to use translatable labels for your site. While it does not allow for fully multilingual sites, you can easily translate labels and short snippets of text to different languages.

It is recommended to use this extension in combination with the Translate extension.

View the full documentation online: Labels docs.

labels's People

Contributors

bobdenotter avatar dadaxr avatar evertalbers avatar gwendolenlynch avatar jan-t3000 avatar jimi75 avatar lswest avatar nestordedios avatar sahassar avatar svanterichter avatar tdammers avatar tobias2k avatar xiaohutai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

labels's Issues

Use of labels in custom extension

Hi there,

How could I use a translation inside a custom extension (bolt 2.2, so older install) ?
In twig I can use {{ l('something') }} but I need it in my php-code.

Simply trying the l('something') method in php results in

Error: Call to undefined function Bolt\Extension\TimOnline\Contact\l()

Hope you can help.

Linebreaks seem to cause a problem

when a translation includes a linebreak, the csv breaks on this point.
example:

{{ l('this is a
translation') }}

This is put in the csv as a part in the label, and the second part in the namespace.

Adding non english characters wipes translation JSON file

I'm trying to build a multilingual site which it's default language is spanish, but whenever I try to a add an accented character (á, é, í, ó, ú, etc.). It clears my JSON file completely.
Here's an example, this code:

{{ ('haz reservación') }}

renders like this:

<mark>haz reservación</mark>

Any guidance with this would be deeply appreciated.

Set fallback language

If i am not mistaken, there's no way to set a fallback language other than the default one.

Composer Error installing Version 2.0

Trying to install the new version 2.0 I got a Composer error:

Composer Error
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package bolt/labels could not be found in any version, there may be a typo in the package name.

Potential causes:

  • A typo in the package name
  • The package is not available in a stable-enough version according to your minimum-stability setting
    see this link for more details.

Read this link for further common problems.

Edit labels broken

If trying to edit labels I get a blank screen with two save buttons... No labels at all, but funny buzz-data in JS. See (beautified) HTML-output:

<div id="navpage-content" class="container-fluid">
    <div class="row">
        <div class="col-xs-12">
            <h1 class="page-header">
                <strong>Edit labels</strong>
            </h1>
        </div>
    </div>

    <form action="/~irata/hotel/bolt/labels/save" method="POST" enctype="multipart/form-data">

        <button class="btn btn-primary" disabled="disabled" id="save-button" type="submit">
            <i class='fa fa-save'></i> Save
        </button>

        <div id="hot-grid" style='margin: 12px 0;'></div>

        <input type="hidden" name="columns" value="[&quot;Label&quot;,&quot;EN&quot;,&quot;DE&quot;]">
        <input type="hidden" name="labels" id="gridfield-labels" value="">

        <button class="btn btn-primary" disabled="disabled" id="save-button-bottom" type="submit">
            <i class='fa fa-save'></i> Save
        </button>

    </form>

    <script>
    jQuery(document).ready(function($) {

      var data = [["badger","badger","Dachs "],["bear","bear","B\u00e4r "],["beaver","beaver","Biber "],["buffalo","buffalo","B\u00fcffel "],["cat","cat","Katze "],["chamois","chamois","Gams , Gemse "],["cow","cow","Rind , Kuh "],["deer (red)","deer (red)","Hirsch "],["dog","dog","Hund "],["donkey","donkey","Esel "],["elephant","elephant","Elefant "],["ermine","ermine","Hermelin "],["ferret","ferret","Frettchen"],["fox","fox","Fuchs "],["goat","goat","Ziege "],["guinea pig","guinea pig","Meerschweinchen "],["hamster","hamster","Hamster "],["hare","hare","Hase "],["hedgehog","hedgehog","Needles "],["horse","horse","Pferd "],["ibex","ibex","Steinbock "],["lynx","lynx","Luchs "],["marmot","marmot","Murmeltier "],["marten","marten","Marder "],["mole","mole","Maulwurf "],["mouse","mouse","Maus"],["otter","otter","Otter "],["pig","pig","Schwein "],["rabbit","rabbit","Kaninchen "],["rat","rat","Ratte "],["sheep","sheep","Schaf "],["shrew","shrew","Spitzmaus "],["squirrel","squirrel","H\u00f6rnchen "],["vole","vole","Schermaus "],["weasel","weasel","Wiesel "],["wild boar","wild boar","Wildschwein "],["wildcat","wildcat","Wildkatze "],["wolf","wolf","Wolf "]];

      var container = document.getElementById('hot-grid');
      var hot = new Handsontable(container,
        {
            autoColumnSize: true,
            minSpareRows: 1,
            width: '100%',
            minCols: 3,
            data: data,
            colHeaders: [ 'Label', 'EN', 'DE' ],
            columnSorting: true,
            sortIndicator: true,
            rowHeaders: false,
            manualRowMove: true,
            contextMenu: true,
            manualColumnResize: true,
            afterRender: updateData,
            afterColumnSort: updateData,
            afterRowMove: updateData
        });
        function updateData(changes, source) {
            if(hot){
                var data = this.getData(0, 0, hot.countRows() - 1, hot.countCols() - 1); // Because #989
                data = data.filter(function(row) {
                    return !_.isEmpty(_.without(row, null));
                });
                jQuery('#gridfield-labels').val(JSON.stringify(data));
                $('#save-button, #save-button-bottom').removeAttr('disabled');
            }
        }

    });
    </script>
</div>

4 / 5 letter language codes

Hi there.
The docs state:

"It's advisable to stick to two-letter language codes."

That would be fine normally, but a client has customers in different countries where language-difference within the base language actually matters.

So I really need 'de-DE' and 'de-CH' on this one (for example).

How can I achieve this?
I believe the code of the extension itself only wants to check on 2 digits.

Error with Bolt 3.0

Bolt 3.0 beta 3
Labels 3.0
add_missing: true
use_fallback: true

When I use a new {{ l('whatever' }} in a twig file I get an error (below).
I hoped that chmodding the labels.json to 0777 would help, but it does not.

bolt_-_fatal_error _-_2016-05-06_08 07 06

No route found for "GET /bolt/labels"

Hey,

I set up a clean and fresh installation of latest bolt (2.2.13), and installed bolt/labels extension (tried 2.0.5 and dev-master) via backend.
However, with everything untouched, unmodified and out-of-the-box it sais 'No route found for "GET /bolt/labels"'.

Did I miss something? Please help!

Thanks in advance!

labels 3.0.6 not working with bolt 3.2.6

throws composer error:

Could not find package bolt/labels at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability

Not sure how to go about this

Faulty link in backend when working in a /en directory

I am using the labels extension in a site in a separate Bolt installation in a myproject.com/en directory.

When I want to edit the labels, the menu in the backend directs me to myproject.com/bolt/labels instead of the correct myproject.com/en/bolt/labels

Manually changing the url actually works, luckily. Is probably an easy fix.

Expose functions like `twigL` to PHP side of things

Move twigL functions into a separate Service class and inject it as app['labels.service'] (or add the functions to the app['labels'] class), then have helper functions exposed:

  • translate($label, $lang = false) exposed for other extensions to use.
  • setCurrentLanguage
  • etc.

Currently, I'm doing the following in my extension:

$labels = $app['labels']->getLabels();
$lang   = mb_strtolower($request->query->get('_locale', 'nl'));
$label  = $app['labels']->cleanLabel('MUH LABEL');
$result = $label;

if (isset($labels[$label][$lang]) && !empty($labels[$label][$lang])) {
    $result = $labels[$label][$lang];
}
elseif ($app['labels.config']->isAddMissing() && empty($labels[$label])) {
    $app['labels']->addLabel($label);
}

// replace 'MUH LABEL' with the string you need to translate
// use $result as the translated label

Problem with create MenuEntry on Bolt 3.3.6

After install Labels on Bolt 3.3.6 coming fatal error.
Solution - change function registerMenuEntries in LabelsExtension.php:

    $menu = new MenuEntry('labels', 'labels');
    $menu->setLabel('Label translations')
        ->setIcon('fa:flag')
        ->setPermission('labels')
    ;

    return [
        $menu,
    ];

impossible to set permissions

In Global permissions tried:

labels:
extensions:labels
extend:labels
and many more with no luck

bolt: 3.1.0
bolt/labels: 3.0.2

Installed failed - no assets folder

[command/00:32:12] > composer require 'bolt/labels' 'dev-master' -d "/Users/Carson/Repos/Godlife/sites/godlife.com/app/extensions" -n --no-ansi
[error/00:32:14] ./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing bolt/labels (dev-master 2612ddf)
Cloning 2612ddf2a113a05953f5b6286fe61046bf928cac

Script Bolt\Composer\ExtensionInstaller::handle handling the post-package-install event terminated with an exception



[UnexpectedValueException] 
RecursiveDirectoryIterator::__construct(/Users/Carson/Repos/Godlife/sites/godlife.com/app/extensions/vendor/bolt/labels/assets): failed to open dir: No such file or directory 

No error when uploading a wrong(?) csv file.

My Excel for mac saves the default 'csv' option, as a semicolon (;) delimited file. When I try to upload this, I get no reaction at all from the uploader.

Preferred behaviour -> See that this is also a valid csv and import it anyway, with 'succes' message
Alternative behaviour -> Display a valid error message 'something is wrong with your file. Upload failed'

Provide a good manual in the readme

The readme is pretty.. ehm... obscure.
It only tells you what tag to use, the rest is probably something you should guess.
I can image the following explanation:

  • What tag
  • What can you add in the config, if any?
  • When is the label added? (a: when the page is loaded)
  • What do you do next? (a: download the csv)
  • What should you do with the csv?
  • What errors can you expect and how to fix this easily

Add a max-width feature/option to columns

If you have very long labels, then you get very broad columns.

My recommendation is to use keys like foo.bar.baz as much as possible anyways; but it still allows for very long values.

A few ideas:

  • have a max-width column set for key column and language columns in configuration file
  • add a button that fits the table on the current screen's viewport (minus left bar) by setting the column widths proportionally. (could toggle between expand and fit-on-screen)

Installation out of the box fails

@bobdenotter
I did some debugging for the labels extension and have found 2 things:

  • when creating a new project with downloading the latest.tar.gz, installing the extension AND adding
    $this->app['htmlsnippets'] = true;
    on line 246 of [Extension.php[(https://github.com/bolt/labels/blob/master/Extension.php#L246)
    the extension is loaded in the backend and I get the editable grid. And I can edit and save labels.

However trying to use them in the frontend does not work. I get english no matter what I try.
{{ lang }} remains empty.

I have an idea about why it doesn't work from looking at your code earlier so I'll look into that and will create a PR at least for the snippet.

The setup I had earlier today was an installation through creating a project with composer composer create-project bolt/composer-install and maybe because the paths and folders in that installation are are different (or something else?) I could not get the assets loaded in the backend. Adding the htmlsnippets line had no effect.
How to solve this I have no clue. Have you any idea?

Labels file rolling back

My labels constantly reset or roll back. I looked into it to see what's causing it. On Slack Bob said that before there was a problem with 404 pages, I tried that and it seemed to be fine. The problem happened when I changed to a language which I had not yet provided any labels.

This is my labels configuration:

# Configuration file for Labels

# The array of supported languages. It's advisable to stick to two-letter language codes.
languages: [ en, fa, tr, ae ]
default: en

# Automatically add missing labels to the translation file?
add_missing: true

# Fallback to the 'default language', if the label is not defined in the selected language?
use_fallback: true

# Option to hide the backend menuitem
#show_menu: false

I am using Bolt 3.4.8 and Labels 3.1.3.

This is what currently have for the labels:
Labels.json

Steps to reproduce:

  • Changed website language to turkish (which has no label translations at the moment)
  • Changed back to English
  • Labels were gone

When I say labels were gone I don't mean all were deleted. This is why I used the term "roll back" above, it seems to just go to a previous version or something.

This is my labels.json file after did the steps above.
Labels.json

I did those steps 2 times and both times this happened.

downloadable file needs extension

The downloaded file is called 'csv'. without any extension.
Please add a .csv extension, so all programs know what to do with it.

(will open multiple issues, because i came upon a couple of issues when working with this)

Cannot install Labels Extension on Bolt 3.28

Hi,

I get this error while trying to install labels (any version 3.*). I'm installing from "Extensions" menu in Bolt panel:

`Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package bolt/bolt could not be found in any version, there may be a typo in the package name.
Problem 2
- bolt/labels 3.0.7 requires bolt/bolt ^3.0 -> no matching package found.
- bolt/labels 3.0.7 requires bolt/bolt ^3.0 -> no matching package found.
- bolt/labels 3.0.7 requires bolt/bolt ^3.0 -> no matching package found.
- Installation request for bolt/labels 3.0.7 -> satisfiable by bolt/labels[3.0.7].

Potential causes:

  • A typo in the package name
  • The package is not available in a stable-enough version according to your minimum-stability setting
    see this link for more details.

Read this link for further common problems.`

I'm stuck here :/ what could be wrong?

[BUG] Taxonomy labels custom routing, interferes with 'Edit labels' route

Hi,

don't know where to put this, but I figured I start out at the labels extension. I have a tags taxonomy type named: 'labels'

I want to view this in the frontend under the route: /locaties/{taxonomytype}/{slug}

Therefor I have a routing:

labels:
  path:  /locaties/{taxonomytype}/{slug}
  defaults:  { _controller: 'Bolt\Controllers\Frontend::taxonomy' }
  requirements:
    taxonomytype: 'labels'

This all works like a charm, however. I now can not access the eedit labels page for the labels extension: /bolt/extend/labels

the page loads with the following error:

NotFoundHttpException in RouterListener.php line 176:
No route found for "GET /bolt/extend/labels" 

Removing the addition in routing.yml solves it. But I want that routing! Where's the bug?

Using Bolt 3.2.9 and Labels 3.0.7

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.