GithubHelp home page GithubHelp logo

Comments (10)

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

From @clayop on July 6, 2015 19:35

This is what I really need. The word order of Korean is opposite to English, so it is very hard to translate the wallet to Korean.

from bitshares-core.

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

From @emfrias on July 6, 2015 20:3

On the c++ side, fc::exceptions are already use name-value pairs for parameter substitution, so word order differences shouldn't be a problem.

See the 'format' and 'data' in the last exception I generated:
Source:

      FC_THROW("Invalid private key ${key}", ("key", wif_key));

JSON:

{
    "code": 0,
    "name": "exception",
    "message": "unspecified",
    "stack": [
        {
            "context": {
                "level": "error",
                "file": "wallet.cpp",
                "line": 1915,
                "method": "import_key",
                "hostname": "",
                "thread_name": "th_a",
                "timestamp": "2015-07-06T19:57:19"
            },
            "format": "Invalid private key ${key}",
            "data": {
                "key": "this_is_not_a_key"
            }
        }
    ]
}

from bitshares-core.

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

From @valzav on July 7, 2015 2:18

Ok, so we already have name-value parameters. What about error code or symbol? This would be more convenient than parsing error text on a GUI side.
Probably the easiest way to add it would be via additional parameter:
FC_THROW("Invalid private key ${key}", ("code":"invalid_private_key")("key", wif_key));

from bitshares-core.

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

From @bytemaster on July 7, 2015 13:9

Code and name are the first two parameters of the exception object. Ben is currently replacing FC_ASSERT with named exceptions with proper error codes.

from bitshares-core.

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

From @emfrias on July 7, 2015 13:19

... beat me to it.

we sort of have a code, but it's not exactly what you want. The codes are embedded in the exception object. In the above example, code was 0 because I used FC_THROW to throw the base class. If I had thrown a specific derived exception, it would have had a meaningful code.

Codes are defined here for the blockchain, they're that number around 30000+:
https://github.com/cryptonomex/graphene/blob/master/libraries/chain/include/graphene/chain/exceptions.hpp#L25-L113

but right now it's common for us to throw the same type of exception in two different places, using two different messages and two sets of key-value pairs. Unless we change the way we throw exceptions, the code won't be enough for translation.

I'm only familiar with gettext, and I think it uses the english string itself for looking up the translations, that might be the the most reliable thing to do.

from bitshares-core.

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

Related: #113

from bitshares-core.

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

From @valzav on July 7, 2015 17:45

@emfrias - good point, I think we need to standardize messages and parameters for all exceptions with the same error code. Maybe add them to FC_DECLARE_DERIVED_EXCEPTION statements?

from bitshares-core.

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

From @theoreticalbts on July 7, 2015 19:41

I should have some code sometime tomorrow. My approach, discussed in #113, is to ideally have each individual place with an exception throw a different one. The result will be several exceptions with identical parameters and error messages. We may wish to collapse these to a single exception for translation purposes.

I propose using a subclassing mechanism to accomplish this collapse. The localization framework should have a way to associate an error message with a particular exception type. When given an exception of derived type D, you check in types in this order: D, parent(D), parent(parent(D)), ..., stopping when you find a type for which there is a message in the current language.

I believe I can write a program to use fc reflection to climb the inheritance tree, resulting in a map from exception code to a list of parent classes. This allows the database to be independent of exception code changes (in the numbering scheme currently proposed, the operation code is included in the exception code, so if operations are re-ordered, exception codes for the reordered operations would change).

from bitshares-core.

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

From @valzav on July 7, 2015 20:5

@theoreticalbts sounds good to me.. but I have a feeling that there might be an easier solution that doesn't involve subclassing. Also if translation is missing in some language we can just default to english.

from bitshares-core.

vikramrajkumar avatar vikramrajkumar commented on July 18, 2024

Not happening

from bitshares-core.

Related Issues (20)

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.