I can see that there is a new keyword type 'attributes' in C23.
Some of it, like [[deprecated]] were used in C11+GNU __attribute__((deprecated)).
I looks like a great update.
I wonder why a usefull keyword as __attribute__((weak)) is not part of the update.
Is this keyword not appreciated by the standard community?
Related
If I have an attribute self.internal/freezer in a class, and I raise an error via (raise (AttributeError f"Sorry! '{attr}' doesn't exist as an attribute!")), how can I get the attribute name to render as internal/freezer instead of hyx_internalXsolidusXfreezer? For example, I already tried (hy.eval attr) with the f-string, but it still came out mangled.
Thanks to #Kodiologist in the comments linking the mangling section in hylang's syntax documentation; unamgling can be achieved via the aptly named hy.unmangle function, documented here as well.
I do have a bunch of OWLDataRanges which look something like this when the toString-method is used:
DataRangeRestriction(xsd:string facetRestriction(pattern "[0-9]{4}-[0-9]{2}-[0-9]{2}[T]{1}[0-9]{2}:[0-9]{2}:[0-9]{2}[Z]{1}"^^xsd:string))
What I want is the part in brackets after "facetRestriction". I guess I have to use some visitor pattern, but I don't really understand how they work.
Thanks in advance!
In Atom, if a package contains snippets, how do you edit them or delete/deactivate some whilst keeping the rest?
I know I can disable the snippets and copy them into Atom->File->Snippets. However, I think that these snippets would exist for all languages whereas packages like languages-html and languages-latex only activate snippets when their respective language is being used. Is there another way?
Snippets defined in snippets.cson take precedence over all snippets provided by packages, because they are loaded later. You can copy & paste the snippets you want to edit to that file and make your edits. Snippets will be limited to the language grammar you specify in the top-level property.
Example
'.source.js':
'console.log':
'prefix': 'log'
'body': 'Unexpectedly, this does not expand to console.log'
This will override the default snippet, which expands log to console.log
I am creating a website using CakePHP that requires translation not only into multiple languages but also multiple phrases per language depending on the type of the logged in user. This will allow the same functionality but with more formal or more friendly language without duplication.
As a very simple example:
Type 1: "Customer", "purchase","shopping cart"
Type 2: "Client", "buy", "basket"
Type 3: "User", "order","invoice"
Each of these types would be available in multiple languages.
I've got the standard localization working in CakePHP (one of the reasons I chose it!) and have the appropriate default.po files in the /Locale/[lang]/LC_MESSAGES/ directory and all is working fine there (thank you to the user who noted on this site that ger needed to be deu to work ;) ).
Before I get too far into the app I'd like to add the phrasing so I can set e.g. the language as French and phrasing as type2. If I was doing this outside of a framework I'd have a matrix look-up to find the correct string based on language and phrase keys but am unsure of how to do this within CakePHP's localization.
Currently I'm using the standard __([string]) convention but as this is early in the development cycle it would be trivial to change if necessary.
I was considering using __d([phrase],[string]) but can't see how to set this without creating my app as a plugin and then I'm back to the same problem with /Locale/
I have been unable to find any example of this in my searches on SO or the cakePHP community sites so would be grateful for any suggestions.
Is there a standard way to do this within cakePHP? if not, what would be a good "best practice" way to implement this?
Edit - following the answer below here's how it was implemented:
in /app/Locale/[lang]/LC_MESSAGES/ I created a new .po files with the new phrasing in them as phrase1.po, phrase2.po etc.
Where I set the language I also set the phrasing where the phrase file matches the name of the po file:
Configure::write('Config.language', 'deu');
Configure::write('App.langDomain', 'phrase1');
and all strings were wrapped with:
__d(Configure::read('App.langDomain', 'string')
And it just works.
Use __d() like this:
__d(Configure::read('App.langDomain'), 'Some string');
In bootstrap.php check the conditions and set App.langDomain based on whatever you need.
__d() has nothing to do with plugins, you can use it everywhere.
And alternative would be to wrap your translations with a custom method, something like
__dd(Configure::read('App.langDomain'), array('foo' => __('String1', 'bar' => __('String2'));
The array is an array of langDomain => stringForThatDomain mappings. Your __dd() method would take the one that is passed in the first argument.
Has anyone found a way of adding a dynamic field level error to an sobject?
I would like to do something like
mySobjectRec.get('fieldname').addError('my error message');
I realise that mySobjectRec.fieldname__c.addError('my error message') works.
Unfortunately it's not possible to do it.
I've searched for workarounds and can find none, the addError methods on SObject use a highly specialised way to reference the field which is to hard code the field reference ahead of the method.
This method is highly specialized because the field identifier is not actually the invoking object—the sObject record is the invoker. The field is simply used to identify the field that should be used to display the error.
how about
mySobjectRec.getSObject('fieldname').addError('error message');
What I am looking at is:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_sobject.htm
I haven't tried it so not sure if it will work, let me know.